diff --git a/info.ss b/info.ss index 971ccd1..b2bf51e 100644 --- a/info.ss +++ b/info.ss @@ -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") diff --git a/javascript/response.ss b/javascript/response.ss index 0514185..750e690 100644 --- a/javascript/response.ss +++ b/javascript/response.ss @@ -15,7 +15,7 @@ ; javascript ; -> ; response -(define (make-js-response +(define (make-javascript-response #:code [code 200] #:message [message #"OK"] #:seconds [seconds (current-seconds)] @@ -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?)]) diff --git a/scribblings/javascript-response.scrbl b/scribblings/javascript-response.scrbl index 875a67b..0c8c21a 100644 --- a/scribblings/javascript-response.scrbl +++ b/scribblings/javascript-response.scrbl @@ -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].}