| 1 | package Yukki::Web::Controller::Redirect; | ||
| 2 | $Yukki::Web::Controller::Redirect::VERSION = '0.991_007'; # TRIAL | ||
| 3 | $Yukki::Web::Controller::Redirect::VERSION = '0.991007'; | ||
| 4 | use v5.24; | ||
| 5 | use utf8; | ||
| 6 | use Moo; | ||
| 7 | |||
| 8 | use Yukki::Error qw( http_throw ); | ||
| 9 | |||
| 10 | use namespace::clean; | ||
| 11 | |||
| 12 | # ABSTRACT: Simple controller for handling internal redirects | ||
| 13 | |||
| 14 | |||
| 15 | sub fire { | ||
| 16 | my ($self, $ctx) = @_; | ||
| 17 | |||
| 18 | my $redirect = $ctx->request->path_parameters->{redirect}; | ||
| 19 | |||
| 20 | http_throw("no redirect URL named") unless $redirect; | ||
| 21 | |||
| 22 | http_throw("Go to $redirect.", { | ||
| 23 | status => 'MovedPermanently', | ||
| 24 | location => $redirect, | ||
| 25 | }); | ||
| 26 | } | ||
| 27 | |||
| 28 | 1; | ||
| 29 | |||
| 30 | __END__ |