aboutsummaryrefslogtreecommitdiff
path: root/examples/http-server
diff options
context:
space:
mode:
Diffstat (limited to 'examples/http-server')
-rw-r--r--examples/http-server/CHANGES.md4
-rw-r--r--examples/http-server/http-server.tm12
2 files changed, 10 insertions, 6 deletions
diff --git a/examples/http-server/CHANGES.md b/examples/http-server/CHANGES.md
index 42ae752c..636f9296 100644
--- a/examples/http-server/CHANGES.md
+++ b/examples/http-server/CHANGES.md
@@ -1,5 +1,9 @@
# Version History
+## v1.1
+
+Version bump for Tomo syntax changes.
+
## v1.0
Initial version
diff --git a/examples/http-server/http-server.tm b/examples/http-server/http-server.tm
index 8e8aff7e..cc99b521 100644
--- a/examples/http-server/http-server.tm
+++ b/examples/http-server/http-server.tm
@@ -74,12 +74,12 @@ func serve(port:Int32, handler:func(request:HTTPRequest -> HTTPResponse), num_th
struct HTTPRequest(method:Text, path:Text, version:Text, headers:[Text], body:Text)
func from_text(text:Text -> HTTPRequest?)
m := text.pattern_captures($Pat'{word} {..} HTTP/{..}{crlf}{..}') or return none
- method := m[1]
- path := m[2].replace_pattern($Pat'{2+ /}', '/')
- version := m[3]
- rest := m[-1].pattern_captures($Pat/{..}{2 crlf}{0+ ..}/) or return none
- headers := rest[1].split_pattern($Pat/{crlf}/)
- body := rest[-1]
+ method := m[1]!
+ path := m[2]!.replace_pattern($Pat'{2+ /}', '/')
+ version := m[3]!
+ rest := m[-1]!.pattern_captures($Pat/{..}{2 crlf}{0+ ..}/) or return none
+ headers := rest[1]!.split_pattern($Pat/{crlf}/)
+ body := rest[-1]!
return HTTPRequest(method, path, version, headers, body)
struct HTTPResponse(body:Text, status=200, content_type="text/plain", headers:{Text=Text}={})