extract method make-headers

This commit is contained in:
Daniel Barlow 2024-09-25 12:23:49 +01:00
parent ed53c967d7
commit ad29d9e100
1 changed files with 10 additions and 6 deletions

View File

@ -46,14 +46,18 @@
(: :sign ca-key))] (: :sign ca-key))]
(crt:toPEM))) (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] (fn handle-sign-csr [out]
(let [body (out:get_body_as_string)] (let [body (out:get_body_as_string)
(doto (headers.new) h (make-headers 200 { :content-type "text/plain" })]
(: :append ":status" :200) (out:write_headers h false)
(: :append :content-type :text/plain)
(out:write_headers false))
(let [req (csr.new body)] (let [req (csr.new body)]
(print :subject (req:getSubject))
(out:write_chunk (new-crt req) true)))) (out:write_chunk (new-crt req) true))))
(fn on-stream [sv out] (fn on-stream [sv out]