aboutsummaryrefslogtreecommitdiff
path: root/examples/http-server/http-server.tm
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-06 22:26:12 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-06 22:26:12 -0400
commit3406515a44b13d0c290c28ac42bd364ce27560c7 (patch)
tree38000658e651ad19b9c8c2590df8fd6bb6faa4d7 /examples/http-server/http-server.tm
parentd8afa73368cdff38125fa1f7d17ad5ce54c84def (diff)
Make string escapes more normal: "\n" for newline, etc. Backticks can be
used to put in literal code without escape sequences.
Diffstat (limited to 'examples/http-server/http-server.tm')
-rw-r--r--examples/http-server/http-server.tm12
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/http-server/http-server.tm b/examples/http-server/http-server.tm
index 3d72c1e8..5b73d1af 100644
--- a/examples/http-server/http-server.tm
+++ b/examples/http-server/http-server.tm
@@ -85,14 +85,14 @@ struct HTTPRequest(method:Text, path:Text, version:Text, headers:[Text], body:Te
struct HTTPResponse(body:Text, status=200, content_type="text/plain", headers:{Text=Text}={})
func bytes(r:HTTPResponse -> [Byte])
body_bytes := r.body.bytes()
- extra_headers := (++: "$k: $v$(\r\n)" for k,v in r.headers) or ""
+ extra_headers := (++: "$k: $v\r\n" for k,v in r.headers) or ""
return "
- HTTP/1.1 $(r.status) OK$\r
- Content-Length: $(body_bytes.length + 2)$\r
- Content-Type: $(r.content_type)$\r
- Connection: close$\r
+ HTTP/1.1 $(r.status) OK\r
+ Content-Length: $(body_bytes.length + 2)\r
+ Content-Type: $(r.content_type)\r
+ Connection: close\r
$extra_headers
- $\r$\n
+ \r\n
".bytes() ++ body_bytes
func _content_type(file:Path -> Text)