diff --git a/main.fnl b/main.fnl index ee52592..560e282 100644 --- a/main.fnl +++ b/main.fnl @@ -8,6 +8,12 @@ (local pkey (require :openssl.pkey)) (local bignum (require :openssl.bignum)) +;; ncall is the opposite of pcall: "non-protected call" +(macro ncall [f] + `(case ,f + ok# ok# + (nil err#) (error err#))) + (fn string->bignum [bytes] (bignum.new (string.format @@ -34,10 +40,10 @@ (out:write_chunk text true)) (fn slurp [filename] - (with-open [f (io.open filename "r")] (f:read "*a"))) + (with-open [f (ncall (io.open filename "r"))] (f:read "*a"))) (fn read-line [filename] - (with-open [f (io.open filename "r")] (f:read "l"))) + (with-open [f (ncall (io.open filename "r"))] (f:read "l"))) (fn assoc [tbl k v & more] (tset tbl k v) @@ -106,12 +112,6 @@ _ (send-error out 404 "not found")))) -;; ncall is the opposite of pcall: "non-protected call" -(macro ncall [f] - `(case ,f - ok# ok# - (nil err#) (error err#))) - (fn new-server [] (let [(addr port) (string.match options.bind-address "(.+):(%d+)$")] (case (server.listen