Bug 29498: Remove usage of deprecated Mojolicious::Routes::Route::detour
[koha.git] / Koha / App / Plugin / RESTV1.pm
1 package Koha::App::Plugin::RESTV1;
2
3 # Copyright 2020 BibLibre
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use Modern::Perl;
21
22 use Mojo::Base 'Mojolicious::Plugin';
23
24 use Koha::REST::V1;
25
26 sub register {
27     my ($self, $app) = @_;
28
29     $app->routes->any('/api')->partial(1)->to(app => Koha::REST::V1->new);
30 }
31
32 1;
33
34 =encoding utf8
35
36 =head1 NAME
37
38 Koha::App::Plugin::RESTV1
39
40 =head1 DESCRIPTION
41
42 Koha App Plugin used to intercept api calls and route them to the dedicated REST API Mojolicious App.
43
44 =head1 METHODS
45
46 =head2 register
47
48 Called at application startup; Sets up a router to catch all calls to /api and pass them through to Koha::REST::V1.
49
50 =cut