Defaults for web-response-header

This commit is contained in:
Tony Garnock-Jones 2016-07-23 11:40:18 -04:00
parent b6e863fa79
commit 796acbeea2
2 changed files with 11 additions and 12 deletions

View File

@ -8,10 +8,10 @@
(struct-out web-request)
(struct-out web-request-header)
(struct-out web-response-header)
(rename-out [web-response-header <web-response-header>])
(struct-out/defaults [make-web-response-header web-response-header])
(struct-out web-response-complete)
(struct-out web-response-chunked)
(rename-out [web-response-websocket <web-response-websocket>])
(struct-out/defaults [make-web-response-websocket web-response-websocket])
@ -61,6 +61,12 @@
(struct websocket-message (id direction body) #:prefab)
(begin-for-declarations
(define-struct-defaults make-web-response-header web-response-header
(#:code [web-response-header-code 200]
#:message [web-response-header-message #"OK"]
#:last-modified-seconds [web-response-header-last-modified-seconds (current-seconds)]
#:mime-type [web-response-header-mime-type #"text/html"]
#:headers [web-response-header-headers '()]))
(define-struct-defaults make-web-response-websocket web-response-websocket
(#:headers [web-response-websocket-headers '()])))

View File

@ -52,11 +52,8 @@
(react (field [done? #f])
(stop-when (rising-edge (done?)))
(assert (web-response-chunked id
(web-response-header 200
#"Slowly"
(current-seconds)
#"text/plain"
'())))
(web-response-header #:message #"Slowly"
#:mime-type #"text/plain")))
(on (asserted (observe (web-response-chunk id _)))
;;
;; TODO: output-response-body/chunked in web-server's response.rkt
@ -82,11 +79,7 @@
(counter (+ (counter) 1))
(send! (web-response-complete
id
(web-response-header 200
#"OK"
(current-seconds)
#"text/plain"
'())
(web-response-header #:mime-type #"text/plain")
(string->bytes/utf-8
(format "Hi there. Your path was ~v, and this is request ~a"
path