View | Details | Raw Unified | Return to bug 37286
Collapse All | Expand All

(-)a/Koha/App/Intranet.pm (-6 lines)
Lines 35-41 sub startup { Link Here
35
    $self->plugin('CGIBinKoha');
35
    $self->plugin('CGIBinKoha');
36
36
37
    # Create routes for API
37
    # Create routes for API
38
    # FIXME This generates routes like this: /api/api/v1/...
39
    $self->plugin('RESTV1');
38
    $self->plugin('RESTV1');
40
39
41
    $self->hook(before_dispatch => \&_before_dispatch);
40
    $self->hook(before_dispatch => \&_before_dispatch);
Lines 54-64 sub _before_dispatch { Link Here
54
    # Remove Koha version from URL
53
    # Remove Koha version from URL
55
    $path =~ s/_\d{2}\.\d{7}\.(js|css)/.$1/;
54
    $path =~ s/_\d{2}\.\d{7}\.(js|css)/.$1/;
56
55
57
    # See FIXME above
58
    if ($path =~ m|^/api/v|) {
59
        $path = '/api' . $path;
60
    }
61
62
    $c->req->url->path->parse($path);
56
    $c->req->url->path->parse($path);
63
}
57
}
64
58
(-)a/Koha/App/Opac.pm (-6 lines)
Lines 35-41 sub startup { Link Here
35
    $self->plugin('CGIBinKoha', opac => 1);
35
    $self->plugin('CGIBinKoha', opac => 1);
36
36
37
    # Create routes for API
37
    # Create routes for API
38
    # FIXME This generates routes like this: /api/api/v1/...
39
    $self->plugin('RESTV1');
38
    $self->plugin('RESTV1');
40
39
41
    $self->hook(before_dispatch => \&_before_dispatch);
40
    $self->hook(before_dispatch => \&_before_dispatch);
Lines 54-64 sub _before_dispatch { Link Here
54
    # Remove Koha version from URL
53
    # Remove Koha version from URL
55
    $path =~ s/_\d{2}\.\d{7}\.(js|css)/.$1/;
54
    $path =~ s/_\d{2}\.\d{7}\.(js|css)/.$1/;
56
55
57
    # See FIXME above
58
    if ($path =~ m|^/api/v|) {
59
        $path = '/api' . $path;
60
    }
61
62
    $c->req->url->path->parse($path);
56
    $c->req->url->path->parse($path);
63
}
57
}
64
58
(-)a/Koha/App/Plugin/RESTV1.pm (-1 / +2 lines)
Lines 26-32 use Koha::REST::V1; Link Here
26
sub register {
26
sub register {
27
    my ($self, $app) = @_;
27
    my ($self, $app) = @_;
28
28
29
    $app->routes->any('/api')->partial(1)->to(app => Koha::REST::V1->new);
29
    my $v1 = Koha::REST::V1->new(config => { route => '/v1' });
30
    $app->routes->any('/api')->partial(1)->to(app => $v1);
30
}
31
}
31
32
32
1;
33
1;
(-)a/Koha/REST/V1.pm (-2 / +3 lines)
Lines 98-107 sub startup { Link Here
98
            }
98
            }
99
        ) unless C4::Context->needs_install; # load only if Koha is installed
99
        ) unless C4::Context->needs_install; # load only if Koha is installed
100
100
101
        my $route = $self->config('route') // '/api/v1';
102
101
        $self->plugin(
103
        $self->plugin(
102
            OpenAPI => {
104
            OpenAPI => {
103
                spec  => $spec,
105
                spec  => $spec,
104
                route => $self->routes->under('/api/v1')->to('Auth#under'),
106
                route => $self->routes->under($route)->to('Auth#under'),
105
            }
107
            }
106
        );
108
        );
107
109
108
- 

Return to bug 37286