dm_cgi_router Module

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.


Uses

  • module~~dm_cgi_router~~UsesGraph module~dm_cgi_router dm_cgi_router module~dm_cgi dm_cgi module~dm_cgi_router->module~dm_cgi module~dm_error dm_error module~dm_cgi_router->module~dm_error module~dm_hash_table dm_hash_table module~dm_cgi_router->module~dm_hash_table module~dm_cgi->module~dm_error module~dm_ascii dm_ascii module~dm_cgi->module~dm_ascii module~dm_hash dm_hash module~dm_cgi->module~dm_hash module~dm_http dm_http module~dm_cgi->module~dm_http module~dm_kind dm_kind module~dm_cgi->module~dm_kind module~dm_mime dm_mime module~dm_cgi->module~dm_mime module~dm_string dm_string module~dm_cgi->module~dm_string module~dm_time dm_time module~dm_cgi->module~dm_time module~dm_util dm_util module~dm_cgi->module~dm_util module~dm_error->module~dm_ascii module~dm_error->module~dm_kind module~dm_hash_table->module~dm_error module~dm_hash_table->module~dm_hash module~dm_hash_table->module~dm_kind module~dm_hash->module~dm_kind module~dm_platform dm_platform module~dm_hash->module~dm_platform iso_fortran_env iso_fortran_env module~dm_kind->iso_fortran_env module~dm_string->module~dm_error module~dm_string->module~dm_kind module~dm_time->module~dm_error module~dm_time->module~dm_kind module~dm_time->module~dm_util module~dm_util->module~dm_error module~dm_util->module~dm_kind

Used by

  • module~~dm_cgi_router~~UsedByGraph module~dm_cgi_router dm_cgi_router module~dmpack dmpack module~dmpack->module~dm_cgi_router

Abstract Interfaces

abstract interface

  • public subroutine dm_cgi_router_callback(env)

    Route callback routine to be invoked by router.

    Arguments

    Type IntentOptional Attributes Name
    type(cgi_env_type), intent(inout) :: env

    CGI environment variables.


Derived Types

type, public ::  cgi_route_type

Route type that stores URI path and callback routine.

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: path

Route path.

procedure(dm_cgi_router_callback), public, pointer, nopass :: callback => null()

Callback routine.

type, public ::  cgi_router_type

Opaque router type that holds the routes.


Functions

public function dm_cgi_router_add(router, route) result(rc)

Adds route to router.

Arguments

Type IntentOptional 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.

Return Value integer

public function dm_cgi_router_create(router, max_routes) result(rc)

Creates a new router with given maximum number of routes in the routes hash table.

Arguments

Type IntentOptional Attributes Name
type(cgi_router_type), intent(out) :: router

Router type.

integer, intent(in) :: max_routes

Max. size of hash table.

Return Value integer

public function dm_cgi_router_get(router, path, route) result(rc)

Returns route of associated path from internal hash table. The passed path string has to be trimmed.

Arguments

Type IntentOptional 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.

Return Value integer

public function dm_cgi_router_set(router, routes) result(rc)

Creates a new router and adds routes to endpoints.

Arguments

Type IntentOptional Attributes Name
type(cgi_router_type), intent(inout) :: router

Router type.

type(cgi_route_type), intent(inout) :: routes(:)

Endpoints.

Return Value integer


Subroutines

public subroutine dm_cgi_router_destroy(router)

Finalises router.

Arguments

Type IntentOptional Attributes Name
type(cgi_router_type), intent(inout) :: router

Router type.

public subroutine dm_cgi_router_dispatch(router, env, http_status)

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.

Arguments

Type IntentOptional 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.