aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2022-11-29 22:40:07 +0000
committers-ol <s+removethis@s-ol.nu>2022-11-29 22:40:07 +0000
commitc138391c50b312e444c40804cc61c265a4b58fa7 (patch)
tree05da02a24ea24c025c830eb6c4c47d96d15bd28a
parentadd dynfn type for non-cacheable evaluation (diff)
downloadmmm-c138391c50b312e444c40804cc61c265a4b58fa7.tar.gz
mmm-c138391c50b312e444c40804cc61c265a4b58fa7.zip
fix logging, 404 handling
-rw-r--r--build/server.moon17
1 files changed, 6 insertions, 11 deletions
diff --git a/build/server.moon b/build/server.moon
index 3338c20..24e4f74 100644
--- a/build/server.moon
+++ b/build/server.moon
@@ -28,7 +28,6 @@ class Server
opts.host = 'localhost' unless opts.host
opts.port = 8000 unless opts.port
opts.onstream = @\stream
- opts.onerror = @\error
@server = server.listen opts
@@ -108,7 +107,7 @@ class Server
facet.type = base
@handle_debug fileder, facet
else if not fileder\has_facet facet.name
- 404, "facet '#{facet.name}' not found in fileder '#{path}'"
+ return 404, "facet '#{facet.name}' not found in fileder '#{path}'"
else
fileder\get facet
@@ -124,16 +123,16 @@ class Server
path = req\get ':path'
path = decodeURI path
- path_facet, type = path\match '(.*):(.*)'
+ path_facet, typ = path\match '(.*):(.*)'
path_facet or= path
path, facet = path_facet\match '(.*)/([^/]*)'
- facet = if facet == '' and (not type or type == '') and method ~= 'GET' and method ~= 'HEAD'
+ facet = if facet == '' and (not typ or typ == '') and method ~= 'GET' and method ~= 'HEAD'
nil
else
- type or= '?'
- type = type\match '%s*(.*)'
- Key facet, type
+ typ or= '?'
+ typ = typ\match '%s*(.*)'
+ Key facet, typ
value = stream\get_body_as_string!
ok, status, body = xpcall @.handle, err_and_trace, @, method, path, facet, value
@@ -154,10 +153,6 @@ class Server
if method ~= 'HEAD'
stream\write_chunk body, true
- error: (sv, ctx, op, err, errno) =>
- msg = "#{op} on #{tostring ctx} failed"
- msg = "#{msg}: #{err}" if err
-
-- usage:
-- moon server.moon [FLAGS] [STORE] [host] [port]
-- * FLAGS - any of the following: