improve method name, use ncall for server.listen
This commit is contained in:
parent
9ef1947211
commit
42aa1d8f0a
12
main.fnl
12
main.fnl
@ -86,22 +86,20 @@
|
||||
(: :sign ca-key))]
|
||||
(crt:toPEM)))
|
||||
|
||||
(fn approved-request? [csr]
|
||||
(fn approve-request? [csr]
|
||||
(let [attr (csr:getAttributes)]
|
||||
(accumulate [found false
|
||||
_ v (ipairs (. attr "challengePassword"))]
|
||||
(or found (= v options.challenge-password)))))
|
||||
|
||||
|
||||
(fn handle-sign-csr [out]
|
||||
(let [req (csr.new (out:get_body_as_string))]
|
||||
(if (approved-request? req)
|
||||
(if (approve-request? req)
|
||||
(do
|
||||
(out:write_headers (make-headers 200 { :content-type "text/plain" }) false)
|
||||
(out:write_chunk (new-crt req) true))
|
||||
(send-error out 400 "missing attributes in CSR"))))
|
||||
|
||||
|
||||
(fn on-stream [sv out]
|
||||
(let [hdrs (out:get_headers)
|
||||
method (hdrs:get ":method")
|
||||
@ -114,14 +112,12 @@
|
||||
|
||||
(fn new-server []
|
||||
(let [(addr port) (string.match options.bind-address "(.+):(%d+)$")]
|
||||
(case (server.listen
|
||||
(ncall (server.listen
|
||||
{
|
||||
:host addr
|
||||
:port (tonumber port)
|
||||
:onstream on-stream
|
||||
})
|
||||
f (doto f (print))
|
||||
(nil e) (error e))))
|
||||
}))))
|
||||
|
||||
(let [s (new-server)]
|
||||
(ncall (s:listen))
|
||||
|
Loading…
Reference in New Issue
Block a user