The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

App::Dochazka::REST::Dispatch - path dispatch

VERSION

Version 0.098

DESCRIPTION

This module contains a single function, is_auth, that processes the "path" from the HTTP request.

is_auth

Takes three parameters: (1) the EID of the employee making the request, (2) the current privilege level of that EID, and (3) the path string. It returns a status object, the level of which can be either 'OK' (authorized) or 'NOT_OK'. If the request is authorized, the payload will contain a reference to a hash that will look like this:

    {
        rout => CODEREF,
        args => [ ... ],
    }

where 'rout' is a reference to the subroutine to be run to obtain the JSON string for the HTTP response and 'args' is a list of arguments to be provided to that function. Also, the extraneous URL part (if any) is appended to the status object as 'extra'.

REQUEST SYNTAX

Documentation of App::Dochazka::REST request syntax. Each section below corresponds to a URL, in which you should replace dochazka.site with the FQDN of your own Dochazka REST server. The full URL is shown only for the first couple entries. All responses are JSON-encoded status objects unless otherwise noted.

http://dochazka.site/

(If this URL is opened in a browser, a HTML page will be displayed. The HTML source code is defined in $mesg->DOCHAZKA_REST_HTML.)

The path in this case will be / (empty path) and the response will be the same as for "version"" in ".

For the sake of brevity, all the remaining paths will omit the http://dochazka.site/ part.

/version

Returns version number of the App::Dochazka::REST that is installed at the site.

/help

Returns a hopefully helpful status object containing a URL where this documentation can be accessed.

/site/[PARAM]

Returns value of the given site param in the payload.

/lookup/employees/nick/[SEARCH_KEY]

(Lookup is always for multiple records. To look up a single record, use /fetch.) Look up employees by nick.

/forbidden

This request always returns 403 Forbidden