@@ -609,7 +609,8 @@ single script, embedded in the configuration file or otherwise, can service
609
609
many different endpoints. Scripts are supposed to implement functions with
610
610
the following signature: ` handle_${METHOD}_${ENDPOINT}(req) ` , where
611
611
` ${METHOD} ` can be a HTTP method (i.e. ` get ` , ` post ` , ` head ` , etc.), and
612
- ` ${ENDPOINT} ` is the desired endpoint to be handled by that function.
612
+ ` ${ENDPOINT} ` is the desired endpoint to be handled by that function. A generic
613
+ ` handle(req) ` function will be called if the specific version doesn't exist.
613
614
614
615
> [ !TIP]
615
616
>
@@ -643,6 +644,9 @@ information from the request, or to set the response, as seen below:
643
644
- ` req:request_date() ` returns the date as it'll be written in the ` Date ` response header.
644
645
- ` req:is_https() ` returns ` true ` if this request is serviced through HTTPS, ` false ` otherwise.
645
646
- ` req:host() ` returns the value of the ` Host ` header if present, otherwise ` nil ` .
647
+ - ` req:http_version() ` returns ` HTTP/1.0 ` or ` HTTP/1.1 ` depending on the request version.
648
+ - ` req:http_method() ` returns a string, in uppercase, with the HTTP method (e.g. ` "GET" ` ).
649
+ - ` req:http_headers() ` returns a table with all headers and their values.
646
650
647
651
Handler functions may return either ` nil ` (in which case, a ` 200 OK ` response
648
652
is generated), or a number matching an HTTP status code. Attempting to return
0 commit comments