certifix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit ad29d9e1004d1a37175211ec435b12e93f7b4115
parent ed53c967d76195ba6115af1580cb621a6cae379e
Author: Daniel Barlow <dan@telent.net>
Date:   Wed, 25 Sep 2024 12:23:49 +0100

extract method make-headers

Diffstat:
Mmain.fnl | 16++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/main.fnl b/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]