Bug 13799: RESTful API with Mojolicious and Swagger2
[koha.git] / Koha / REST / V1.pm
blob39cdab90d1a18a3c58b4c0d1d8f7766ed371b237
1 package Koha::REST::V1;
3 use Modern::Perl;
4 use Mojo::Base 'Mojolicious';
6 sub startup {
7 my $self = shift;
9 my $route = $self->routes->under->to(
10 cb => sub {
11 my $c = shift;
12 my $user = $c->param('user');
13 # Do the authentication stuff here...
14 $c->stash('user', $user);
15 return 1;
19 # Force charset=utf8 in Content-Type header for JSON responses
20 $self->types->type(json => 'application/json; charset=utf8');
22 $self->plugin(Swagger2 => {
23 route => $route,
24 url => $self->home->rel_file("api/v1/swagger.json"),
25 });