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

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/c)

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/c)

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/c)

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/c)

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.