On this page:
make
Version: 4.1

5.12 Serving Scheme Servlets

 (require web-server/dispatchers/dispatch-servlets)

The web-server/dispatchers/dispatch-servlets module defines a dispatcher constructor that runs servlets written in Scheme.

(make

 

config:scripts

 

 

 

#:url->path url->path

 

 

 [

#:make-servlet-namespace make-servlet-namespace

 

 

 

#:responders-servlet-loading responders-servlet-loading

 

 

 

#:responders-servlet responders-servlet

 

 

 

#:timeouts-default-servlet timeouts-default-servlet])

 

 

 

(-> void)

 

dispatcher?

  config:scripts : (box/c cache-table?)

  url->path : url->path?

  

make-servlet-namespace

 

:

 

make-servlet-namespace?

 

 

 

=

 

(make-make-servlet-namespace)

  

responders-servlet-loading

 

:

 

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

 

 

 

=

 

servlet-loading-responder

  

responders-servlet

 

:

 

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

 

 

 

=

 

(gen-servlet-responder "servlet-error.html")

  timeouts-default-servlet : integer? = 30

The first returned value is a procedure that refreshes the servlet code cache.

The dispatcher does the following: If the request URL contains a continuation reference, then it is invoked with the request. Otherwise, url->path is used to resolve the URL to a path. The path is evaluated as a module, in a namespace constructed by make-servlet-namespace. If this fails then responders-servlet-loading is used to format a response with the exception. If it succeeds, then start export of the module is invoked. If there is an error when a servlet is invoked, then responders-servlet is used to format a response with the exception.

Servlets that do not specify timeouts are given timeouts according to timeouts-default-servlet.