► |  | 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.2 | Setting Up Servlets

3.2.1 | Internal Servlet Representation

On this page:

make-v1.servlet
make-v2.servlet
make-stateless.servlet
default-module-specs
path->servlet/ c
make-default-path->servlet
3.2.1`` Internal Servlet Representation
servlet

Version: 4.1.4
top← prev up next →

#### 3.2`` Setting Up Servlets

(require web-server/servlet/setup)

This module is used internally to build and load servlets. It may be useful to those who are trying to extend the server.

(make-v1.servlet directory timeout start) → servlet?
directory : path-string?
timeout : integer?
start : (request? . -> . response?)

Creates a version 1 servlet that uses directory as its current directory, a timeout manager with a timeout timeout, and start as the request handler.

(make-v2.servlet directory manager start) → servlet?
directory : path-string?
manager : manager?
start : (request? . -> . response?)

Creates a version 2 servlet that uses directory as its current directory, a manager as the continuation manager, and start as the request handler.

(make-stateless.servlet directory start) → servlet?
directory : path-string?
start : (request? . -> . response?)

Creates a stateless web-server servlet that uses directory as its current directory and start as the request handler.

default-module-specs : (listof module-path?)

The modules that the Web Server needs to share with all servlets.

path->servlet/c : contract?

Equivalent to (-> path? servlet?).

(make-default-path->servlet |
| [ | #:make-servlet-namespace make-servlet-namespace |
|  | #:timeouts-default-servlet timeouts-default-servlet]) |

→ path->servlet/c

| make-servlet-namespace |  | : |  | make-servlet-namespace/c
|  |  | = |  | (make-make-servlet-namespace)

timeouts-default-servlet : integer? = 30

Constructs a procedure that loads a servlet from the path in a namespace created with make-servlet-namespace, using a timeout manager with timeouts-default-servlet as the default timeout (if no manager is given.)

##### 3.2.1`` Internal Servlet Representation

(require web-server/private/servlet)

(struct |  | servlet |  | (custodian namespace manager directory handler)
|  | #:mutable)

custodian : custodian?
namespace : namespace?
manager : manager?
directory : path-string?
handler : (request? . -> . response?)

Instances of this structure hold the necessary parts of a servlet: the custodian responsible for the servlet’s resources, the namespace the servlet is executed within, the manager responsible for the servlet’s continuations, the current directory of the servlet, and the handler for all requests to the servlet.

top← prev up next →