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::Resource - web resource definition

VERSION

Version 0.086

SYNOPSIS

In PSGI file:

    use Web::Machine;

    Web::Machine->new(
        resource => 'App::Dochazka::REST::Resource',
    )->to_app;

DESCRIPTION

This is where we provide our own versions of various methods used by our "web framework": Web::Machine.

Methods/attributes not defined in this module will be inherited from Web::Machine::Resource.

METHODS

content_types_provided

Web::Machine calls this routine to determine how to generate the response body. It says: "generate responses in JSON using the 'render' method".

render_json

Encode the context as a JSON string.

render_html

Whip out some HTML to educate the clueless (including ourselves).

context

This method is used to store the request "context", i.e. the part of the URL after the hostname.

charsets_provided

This method causes Web::Machine to encode the response body in UTF-8.

default_charset

Really use UTF-8 all the time.

allowed_methods

Determines which HTTP methods we recognize.

is_authorized

It says "authorized", but it means authentication.

resource_exists

Path dispatcher method. (The "path" is the part of the URL following the hostname.) This is the meat of the REST server, where we determine what the responses will be to various requests.