Add a helper function to render text
This commit is contained in:
parent
a92d4d0cf2
commit
16879a8182
1 changed files with 11 additions and 0 deletions
|
|
@ -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))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue