3.1.4 Standard Responders
(require web-server/configuration/responders) |
"configuration/responders.ss" provides some functions that help constructing HTTP responders. These functions are used by the default dispatcher constructor (see Web Server Unit) to turn the paths given in the configuration-table into responders for the associated circumstance.
| ||||||||||||||||||||||||||||
http-code : natural-number/c | ||||||||||||||||||||||||||||
short-version : string? | ||||||||||||||||||||||||||||
text-file : string? | ||||||||||||||||||||||||||||
header : header? |
Generates a response/full with the given http-code and short-version as the corresponding fields; with the content of the text-file as the body; and, with the headers as, you guessed it, headers.
This does not cause redirects to a well-known URL, such as "conf/not-found.html", but rather use the contents of "not-found.html" (for example) as its contents. Therefore, any relative URLs in text-file are relative to whatever URL file-response is used to respond to. Thus, you should probably use absolute URLs in these files.
(servlet-loading-responder url exn) → response/c |
url : url? |
exn : exn? |
Gives exn to the current-error-handler and response with a stack trace and a "Servlet didn’t load" message.
(gen-servlet-not-found file) → ((url url?) . -> . response/c) |
file : path-string? |
Returns a function that generates a standard "Servlet not found." error with content from file.
(servlet-error-responder url exn) → response/c |
url : url? |
exn : exn? |
Gives exn to the current-error-handler and response with a stack trace and a "Servlet error" message.
(gen-servlet-responder file) |
→ ((url url?) (exn any/c) . -> . response/c) |
file : path-string? |
Prints the exn to standard output and responds with a "Servlet error." message with content from file.
(gen-servlets-refreshed file) → (-> response/c) |
file : path-string? |
Returns a function that generates a standard "Servlet cache refreshed." message with content from file.
(gen-passwords-refreshed file) → (-> response/c) |
file : path-string? |
Returns a function that generates a standard "Passwords refreshed." message with content from file.
(gen-authentication-responder file) |
→ ((url url?) (header header?) . -> . response/c) |
file : path-string? |
Returns a function that generates an authentication failure error with content from file and header as the HTTP header.
(gen-protocol-responder file) → ((url url?) . -> . response/c) |
file : path-string? |
Returns a function that generates a "Malformed request" error with content from file.
(gen-file-not-found-responder file) |
→ ((req request?) . -> . response/c) |
file : path-string? |
Returns a function that generates a standard "File not found" error with content from file.
(gen-collect-garbage-responder file) → (-> response/c) |
file : path-string? |
Returns a function that generates a standard "Garbage collection run" message with content from file.