2.17 Wrapping Requests & Responses
procedure
(make servlet req-trans res-trans) → dispatcher/c
servlet : (-> request? response?) req-trans : (-> request? request?) res-trans : (-> response? response?)
If you’re not interested in transforming requests, pass in identity (the identity function) for req-trans. Similarly, using identity for res-trans will cause responses to pass through unchanged. (Using identity for both req-trans and res-trans is equivalent to just using servlet as-is.)
A typical use case for this dispatcher would be to inject headers into requests or responses. Similarly, functionally updating existing headers also fits into this pattern. Since the entire request – not just its headers – is available to req-trans (and similarly for the response and res-trans), arbitrary rewriting of request/response bodies is possible. Side effects in req-trans and res-trans are permitted as long as make’s contracts are adhered to.
Changed in version 1.9 of package web-server-lib: First version of this dispatcher