Created
February 25, 2012 00:28
-
-
Save kits/1904869 to your computer and use it in GitHub Desktop.
Mojolicious redirect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
get '/' => sub { | |
my $self = shift; | |
$self->redirect_to('/foo'); | |
}; | |
app->start; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ telnet localhost 3000 | |
Trying 127.0.0.1... | |
Connected to localhost. | |
Escape character is '^]'. | |
GET / HTTP/1.0 | |
Host: 127.0.0.1 | |
HTTP/1.1 302 Found | |
Connection: close | |
X-Powered-By: Mojolicious (Perl) | |
Location: http://127.0.0.1/foo | |
Date: Sat, 25 Feb 2012 00:27:30 GMT | |
Content-Length: 0 | |
Server: Mojolicious (Perl) | |
Connection closed by foreign host. | |
$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ telnet localhost 3000 | |
Trying 127.0.0.1... | |
Connected to localhost. | |
Escape character is '^]'. | |
GET / HTTP/1.0 | |
Host: hoge.fuga | |
HTTP/1.1 302 Found | |
Connection: close | |
X-Powered-By: Mojolicious (Perl) | |
Location: http://hoge.fuga/foo | |
Date: Sat, 25 Feb 2012 02:44:01 GMT | |
Content-Length: 0 | |
Server: Mojolicious (Perl) | |
Connection closed by foreign host. | |
$ | |
# request時のHostヘッダの値が、そのままLocationヘッダのURLの | |
# ホスト名として使われるようです。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment