Skip to content

Commit b0be776

Browse files
authored
Merge pull request metacpan#879 from metacpan/ssoriche/mount-on-v1
Add route for `/v1` path
2 parents ade4ddf + ae595ae commit b0be776

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/MetaCPAN/API.pm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,20 @@ sub _set_up_routes {
145145
$self->plugin( 'Minion::Admin' => { route => $admin->any('/minion') } );
146146
$self->plugin(
147147
'OpenAPI' => { url => $self->home->rel_file('root/static/v1.yml') } );
148+
149+
# This route is for when nginx gets updated to no longer strip the `/v1` path.
150+
# By retaining the `/v1` path the OpenAPI spec is picked up and passed
151+
# through Mojolicous. The `rewrite` parameter is stripping the `/v1` before
152+
# it is passed to Catalyst allowing the previous logic to be followed.
153+
$self->plugin(
154+
MountPSGI => {
155+
'/v1' => $self->home->child('app.psgi')->to_string,
156+
rewrite => 1
157+
}
158+
);
159+
160+
# XXX Catch cases when `v1` has been stripped by nginx until migration is complete
161+
# XXX then this path can be removed.
148162
$self->plugin(
149163
MountPSGI => { '/' => $self->home->child('app.psgi')->to_string } );
150164

0 commit comments

Comments
 (0)