From 5fc7577b5a3bc2c445522dfd5b287e1c6eddc3e9 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 31 Aug 2025 23:33:22 -0400 Subject: Switch to using optional return values for list indexing. --- examples/http-server/http-server.tm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'examples/http-server/http-server.tm') 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}={}) -- cgit v1.2.3