On this page:
file-response
servlet-loading-responder
gen-servlet-not-found
gen-servlet-responder
gen-servlets-refreshed
gen-passwords-refreshed
gen-authentication-responder
gen-protocol-responder
gen-file-not-found-responder
gen-collect-garbage-responder
Version: 4.1

4.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.

(file-response

 

http-code

 

 

 

 

 

 

short-version

 

 

 

 

 

 

text-file

 

 

 

 

 

 

header ...)

 

 

response?

  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.

(servlet-loading-responder url exn)  response?

  url : url?

  exn : any/c

Prints the exn to standard output and responds with a "Servlet didn’t load." message.

(gen-servlet-not-found file)  ((url url?) . -> . response?)

  file : path-string?

Returns a function that generates a standard "Servlet not found." error with content from file.

(gen-servlet-responder file)

  ((url url?) (exn any/c) . -> . response?)

  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?)

  file : path-string?

Returns a function that generates a standard "Servlet cache refreshed." message with content from file.

(gen-passwords-refreshed file)  (-> response?)

  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?)

  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?)

  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?)

  file : path-string?

Returns a function that generates a standard "File not found" error with content from file.

(gen-collect-garbage-responder file)  (-> response?)

  file : path-string?

Returns a function that generates a standard "Garbage collection run" message with content from file.