19.0.0 released Nov 08, 2023
Request handler

Purpose: Define a request handler.

request-handler <request path>
    <any code>
end-request-handler

request-handler starts the implementation of a request handler for <request path> (see request-URL), which is <any code> up to end-request-handler. <request path> is not quoted.

A <request path> can be a request name (i.e. without any forward slashes) or a path consisting of any number of path segments. A request path can have alphanumeric characters, hyphens, underscores and forward slashes, and can start only with an alphabetic character or a forward slash.

For example, a <request path> can be "wine_items" or "/wine-items" "/items/wine" etc. In general, it represents the nature of a request, such as an action on an object, a resource path handled by it etc. There is no specific way to interpret a request path, and you can construct it in a way that works for you.

Note that you can also use "%%" instead of either request-handler or end-request-handler or both.

request-handler will decorate the request path to produce a function name by substituting inner forward slashes with double underscores, and hyphens with a single underscore. For example, <request path> of "/items/wine" would translate to a C function "items__wine", and such function takes no arguments and returns no value, i.e. its signature would be "void items__wine()"
Examples
The following request-handler implements a C function "void items__wines__red_wine()":
request-handler  /items/wines/red-wine
    out-header default
    @This is a request handler to display a list of red wines!
end-request-handler

Another way to write this is:
%%  /items/wines/red-wine
    out-header default
    @This is a request handler to display a list of red wines!
%%

See also
Requests
after-request-handler  
before-request-handler  
building-URL  
getting-URL  
global-request-data  
non-request  
normalized-URL  
request  
request-handler  
request-URL  
startup-handler  
vely-dispatch-request    
See all
documentation


You are free to copy, redistribute and adapt this web page (even commercially), as long as you give credit and provide a dofollow link back to this page - see full license at CC-BY-4.0. Copyright (c) 2019-2023 Dasoftver LLC. Vely and elephant logo are trademarks of Dasoftver LLC. The software and information on this web site are provided "AS IS" and without any warranties or guarantees of any kind. Icons from table-icons.io copyright Paweł Kuna, licensed under MIT license.