On this page:
top
up

2.1GeneralπŸ”— i

package: web-server-lib
This module provides a few functions for dispatchers in general.

Equivalent to (-> connection? request? any ).

Changed in version 1.3 of package web-server-lib: Weakened the range contract to allow any

Equivalent to (symbols 'v1)

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

procedure

( next-dispatcher )any

Raises a exn:dispatcher

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 (ruleinner)
(lambda (connreq)
;Call the inner dispatcher...
(innerconn
;with a new request object...
;with a new URL!
[request-uri (rule(request-uri req))]))))

top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /