check io.open return
This commit is contained in:
parent
ba3795e3f2
commit
9ef1947211
16
main.fnl
16
main.fnl
|
@ -8,6 +8,12 @@
|
||||||
(local pkey (require :openssl.pkey))
|
(local pkey (require :openssl.pkey))
|
||||||
(local bignum (require :openssl.bignum))
|
(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]
|
(fn string->bignum [bytes]
|
||||||
(bignum.new
|
(bignum.new
|
||||||
(string.format
|
(string.format
|
||||||
|
@ -34,10 +40,10 @@
|
||||||
(out:write_chunk text true))
|
(out:write_chunk text true))
|
||||||
|
|
||||||
(fn slurp [filename]
|
(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]
|
(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]
|
(fn assoc [tbl k v & more]
|
||||||
(tset tbl k v)
|
(tset tbl k v)
|
||||||
|
@ -106,12 +112,6 @@
|
||||||
_
|
_
|
||||||
(send-error out 404 "not found"))))
|
(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 []
|
(fn new-server []
|
||||||
(let [(addr port) (string.match options.bind-address "(.+):(%d+)$")]
|
(let [(addr port) (string.match options.bind-address "(.+):(%d+)$")]
|
||||||
(case (server.listen
|
(case (server.listen
|
||||||
|
|
Loading…
Reference in New Issue