Add a helper function to render text

This commit is contained in:
Christopher Baines 2019-12-26 09:04:46 +00:00
parent a92d4d0cf2
commit 16879a8182

View file

@ -36,6 +36,7 @@
render-static-asset render-static-asset
render-html render-html
render-json render-json
render-text
not-found not-found
unprocessable-entity unprocessable-entity
created created
@ -156,6 +157,16 @@
(lambda (port) (lambda (port)
(scm->json json port)))) (scm->json json port))))
(define* (render-text text #:key (extra-headers '())
(code 200))
(list (build-response
#:code code
#:headers (append extra-headers
'((content-type . (text/plain))
(vary . (accept)))))
(lambda (port)
(display text port))))
(define (not-found uri) (define (not-found uri)
(list (build-response #:code 404) (list (build-response #:code 404)
(string-append "Resource not found: " (uri->string uri)))) (string-append "Resource not found: " (uri->string uri))))