On this page:
dispatcher/ c
dispatcher-interface-version/ c
exn: dispatcher
next-dispatcher

2.1 General

This module provides a few functions for dispatchers in general.

Equivalent to (symbols 'v1)

(struct exn:dispatcher ()
  #:extra-constructor-name make-exn:dispatcher)
An exception thrown to indicate that a dispatcher does not apply to a particular request.

As the dispatcher/c contract suggests, a dispatcher is a function that takes a connection and request object and does something to them. Mostly likely it will generate some response and output it on the connection, but it may do something different. For example, it may apply some test to the request object, perhaps checking for a valid source IP address, and error if the test is not passed, and call next-dispatcher otherwise.

Consider the following example dispatcher, that captures the essence of URL rewriting:
  ; (url? -> url?) dispatcher/c -> dispatcher/c
  (lambda (rule inner)
    (lambda (conn req)
      ; Call the inner dispatcher...
      (inner conn
             ; with a new request object...
             (struct-copy request req
                          ; with a new URL!
                          [request-uri (rule (request-uri req))]))))