mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 11:50:28 +02:00
web.texi: handler return types documentation
* doc/ref/web.texi (Web Server): More docs on handler return types.
This commit is contained in:
parent
2ebdf6b555
commit
09b7459b49
1 changed files with 14 additions and 7 deletions
|
@ -1325,13 +1325,20 @@ If the read failed, the @code{read} hook may return #f for the client
|
||||||
socket, request, and body.
|
socket, request, and body.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
A user-provided handler procedure is called, with the request
|
A user-provided handler procedure is called, with the request and body
|
||||||
and body as its arguments. The handler should return two
|
as its arguments. The handler should return two values: the response,
|
||||||
values: the response, as a @code{<response>} record from @code{(web
|
as a @code{<response>} record from @code{(web response)}, and the
|
||||||
response)}, and the response body as a string, bytevector, or
|
response body as bytevector, or @code{#f} if not present.
|
||||||
@code{#f} if not present. We also allow the response to be simply an
|
|
||||||
alist of headers, in which case a default response object is
|
The respose and response body are run through @code{sanitize-response},
|
||||||
constructed with those headers.
|
documented below. This allows the handler writer to take some
|
||||||
|
convenient shortcuts: for example, instead of a @code{<response>}, the
|
||||||
|
handler can simply return an alist of headers, in which case a default
|
||||||
|
response object is constructed with those headers. Instead of a
|
||||||
|
bytevector for the body, the handler can return a string, which will be
|
||||||
|
serialized into an appropriate encoding; or it can return a procedure,
|
||||||
|
which will be called on a port to write out the data. See the
|
||||||
|
@code{sanitize-response} documentation, for more.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
The @code{write} hook is called with three arguments: the client
|
The @code{write} hook is called with three arguments: the client
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue