Basic URI router for CGI. Depending on the path in the CGI environment
variable PATH_INFO
, a callback is invoked that returns the response of
that URI.
Route callback routine to be invoked by router.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(cgi_env_type), | intent(inout) | :: | env |
CGI environment variables. |
Route type that stores URI path and callback routine.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=:), | public, | allocatable | :: | path |
Route path. |
||
procedure(dm_cgi_router_callback), | public, | pointer, nopass | :: | callback | => | null() |
Callback routine. |
Opaque router type that holds the routes.
Adds route to router.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(cgi_router_type), | intent(inout) | :: | router |
Router type. |
||
type(cgi_route_type), | intent(inout), | target | :: | route |
Route to add to routing table. |
Creates a new router with given maximum number of routes in the routes hash table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(cgi_router_type), | intent(out) | :: | router |
Router type. |
||
integer, | intent(in) | :: | max_routes |
Max. size of hash table. |
Returns route of associated path from internal hash table. The passed path string has to be trimmed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(cgi_router_type), | intent(inout) | :: | router |
Router type. |
||
character(len=*), | intent(in) | :: | path |
URI. |
||
type(cgi_route_type), | intent(out), | pointer | :: | route |
Associated route. |
Creates a new router and adds routes to endpoints.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(cgi_router_type), | intent(inout) | :: | router |
Router type. |
||
type(cgi_route_type), | intent(inout) | :: | routes(:) |
Endpoints. |
Finalises router.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(cgi_router_type), | intent(inout) | :: | router |
Router type. |
Searches the router hash table for path in CGI environment variable
PATH_INFO
, and calls the associated subroutine of the route. If no
route has been found, HTTP_NOT_FOUND
is returned in http_status
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(cgi_router_type), | intent(inout) | :: | router |
Router type. |
||
type(cgi_env_type), | intent(inout) | :: | env |
CGI environment variables. |
||
integer, | intent(out) | :: | http_status |
Optional status. |