aboutsummaryrefslogtreecommitdiff
path: root/examples/http-server/http-server.tm
diff options
context:
space:
mode:
Diffstat (limited to 'examples/http-server/http-server.tm')
-rw-r--r--examples/http-server/http-server.tm6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/http-server/http-server.tm b/examples/http-server/http-server.tm
index f7338b91..56ba3683 100644
--- a/examples/http-server/http-server.tm
+++ b/examples/http-server/http-server.tm
@@ -17,7 +17,7 @@ use ./connection-queue.tm
func serve(port:Int32, handler:func(request:HTTPRequest -> HTTPResponse), num_threads=16):
connections := ConnectionQueue()
- workers := &[:@pthread_t]
+ workers : &[@pthread_t] = &[]
for i in num_threads:
workers:insert(pthread_t.new(func():
repeat:
@@ -82,7 +82,7 @@ struct HTTPRequest(method:Text, path:Text, version:Text, headers:[Text], body:Te
body := rest[-1]
return HTTPRequest(method, path, version, headers, body)
-struct HTTPResponse(body:Text, status=200, content_type="text/plain", headers={:Text=Text}):
+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 ""
@@ -114,7 +114,7 @@ enum RouteEntry(ServeFile(file:Path), Redirect(destination:Text)):
return HTTPResponse("Found", 302, headers={"Location"=destination})
func load_routes(directory:Path -> {Text=RouteEntry}):
- routes := &{:Text=RouteEntry}
+ routes : &{Text=RouteEntry} = &{}
for file in (directory ++ (./*)):glob():
skip unless file:is_file()
contents := file:read() or skip