Skip to content

Commit

Permalink
Added make-javascript-response as a synonym for make-js-response.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Gurnell committed Sep 14, 2009
1 parent 998abda commit 35eb163
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
3 changes: 2 additions & 1 deletion info.ss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
(ul (li "replaced the " (tt "render-pretty-javascript?") " parameter with " (tt "javascript-rendering-mode") ";")
(li "added " (tt "javascript->packed-string") ";")
(li "fixed bug that disallowed named function declarations within " (tt "!begin") " blocks;")
(li "better documentation of Javascript syntax."))))
(li "better documentation of Javascript syntax;")
(li "added " (tt "make-javascript-response") " as a synonym for " (tt "make-js-response") "."))))

(define primary-file "mirrors.ss")

Expand Down
27 changes: 19 additions & 8 deletions javascript/response.ss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
; javascript
; ->
; response
(define (make-js-response
(define (make-javascript-response
#:code [code 200]
#:message [message #"OK"]
#:seconds [seconds (current-seconds)]
Expand All @@ -27,13 +27,24 @@
(make-response/full code message seconds mime-type headers
(list (string+bytes->content (javascript->string content))))))

; Contract as above.
(define make-js-response
make-javascript-response)

; Provide statements -----------------------------

(provide/contract
[make-js-response (->* (javascript?)
(#:code integer?
#:message (or/c string? bytes?)
#:seconds integer?
#:mime-type (or/c string? bytes?)
#:headers (listof header?))
response/full?)])
[make-javascript-response (->* (javascript?)
(#:code integer?
#:message (or/c string? bytes?)
#:seconds integer?
#:mime-type (or/c string? bytes?)
#:headers (listof header?))
response/full?)]
[make-js-response (->* (javascript?)
(#:code integer?
#:message (or/c string? bytes?)
#:seconds integer?
#:mime-type (or/c string? bytes?)
#:headers (listof header?))
response/full?)])
10 changes: 9 additions & 1 deletion scribblings/javascript-response.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@ The @scheme['fast] rendering mode is extremely naive: it inserts extra parenthes

@section{Sending HTTP responses with Javascript content}

@defproc[(make-javascript-response [#:code code integer 200]
[#:message message string "OK"]
[#:seconds seconds integer (current-seconds)]
[#:mime-type mime-type (U string bytes) #"text/javascript; charset=utf-8"]
[#:headers headers (alistof symbol string) no-cache-http-headers]
[content javascript-statement]) response]{
Takes a @scheme[js] statement and wraps it in an HTTP response object that can be used with the PLT web server (including procedures such as @scheme[send/suspend] and @scheme[send/suspend/dispatch]). The keyword arguments correspond to the first five arguments of @scheme[make-response/full].}

@defproc[(make-js-response [#:code code integer 200]
[#:message message string "OK"]
[#:seconds seconds integer (current-seconds)]
[#:mime-type mime-type (U string bytes) #"text/javascript; charset=utf-8"]
[#:headers headers (alistof symbol string) no-cache-http-headers]
[content javascript-statement]) response]{
Takes a @scheme[js] statement and wraps it in an HTTP response object that can be used with the PLT web server (including procedures such as @scheme[send/suspend] and @scheme[send/suspend/dispatch]). The keyword arguments correspond to the first five arguments of @scheme[make-response/full].}
An alias for @scheme[make-javascript-response].}

0 comments on commit 35eb163

Please sign in to comment.