► |  | Web Server: PLT HTTP Server

1 | Running the Web Server
2 | Writing Servlets
3 | Extending the Web Server
4 | Troubleshooting and Tips
5 | Acknowledgements
| Index

► | 3 | Extending the Web Server

3.1 | Configuration
3.2 | Setting Up Servlets
3.3 | Dispatchers
3.4 | Web Config Unit
3.5 | Web Server Unit
3.6 | Internal

▼ | 3.1 | Configuration

3.1.1 | Configuration Table Structure
3.1.2 | Configuration Table
3.1.3 | Servlet Namespaces
3.1.4 | Standard Responders

On this page:

file-response
servlet-loading-responder
gen-servlet-not-found
servlet-error-responder
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
top← prev up next →

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

(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 : 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?)
file : path-string?

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

(servlet-error-responder url exn) → response?
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?)
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.

top← prev up next →