extract method make-headers
This commit is contained in:
parent
ed53c967d7
commit
ad29d9e100
16
main.fnl
16
main.fnl
@ -46,14 +46,18 @@
|
||||
(: :sign ca-key))]
|
||||
(crt:toPEM)))
|
||||
|
||||
(fn make-headers [status attributes]
|
||||
(let [h (headers.new)]
|
||||
(h:append ":status" (tostring status))
|
||||
(each [k v (pairs attributes)]
|
||||
(h:append k v))
|
||||
h))
|
||||
|
||||
(fn handle-sign-csr [out]
|
||||
(let [body (out:get_body_as_string)]
|
||||
(doto (headers.new)
|
||||
(: :append ":status" :200)
|
||||
(: :append :content-type :text/plain)
|
||||
(out:write_headers false))
|
||||
(let [body (out:get_body_as_string)
|
||||
h (make-headers 200 { :content-type "text/plain" })]
|
||||
(out:write_headers h false)
|
||||
(let [req (csr.new body)]
|
||||
(print :subject (req:getSubject))
|
||||
(out:write_chunk (new-crt req) true))))
|
||||
|
||||
(fn on-stream [sv out]
|
||||
|
Loading…
Reference in New Issue
Block a user