NAME

WWW::Suffit::Plugin::API - The API Suffit plugin

SYNOPSIS

use Mojo::Base 'WWW::Suffit::Server';

sub startup {
    my $self = shift->SUPER::startup();
    $self->plugin('API', {
        prefix_path => "/api",
        prefix_name => "api",
    });

    # . . .
}

sub startup {
    my $self = shift->SUPER::startup(
        init_api_routes => 'on',
        api_routes_opts => {
            prefix_path => "/api",
            prefix_name => "api",
        }
    );

    # . . .
}

DESCRIPTION

The API Suffit plugin

This plugin requires WWW::Suffit::Plugin::AuthDB plugin

OPTIONS

This plugin supports the following options

prefix_name

prefix_name => "api"

This option defines prefix of api route name

Default: 'api'

prefix_path

prefix_path => "/api"

This option defines prefix of api route

Default: '/api'

HELPERS

This plugin implements the following helpers

api_prefix_name

my $api_prefix_name = $c->api_prefix_name;

Returns the api prefix name

Default: api

api_prefix_path

my $api_prefix_path = $c->api_prefix_path;

Returns the api prefix path

Default: /api

METHODS

This plugin inherits all methods from Mojolicious::Plugin and implements the following new ones

register

This method register the plugin and helpers in Mojolicious application

$plugin->register(Mojolicious->new, {
    prefix_path => "/api",
    prefix_name => "api",
});

Register plugin in Mojolicious application

SEE ALSO

Mojolicious, WWW::Suffit::Server, WWW::Suffit::AuthDB, WWW::Suffit::Plugin::AuthDB

AUTHOR

Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2024 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/