1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/opt/perl use Mojolicious::Lite; app->hook(after_build_tx => sub { my ($tx, $app) = @_; $tx->req->on(finish => sub { my $msg = shift; $msg->parse({HTTP_HOST => "127.0.0.1:12345"}); }); }); get '/' => sub { my $c = shift; $c->render(text => $c->url_for("/")->to_abs); }; app->start;
You can clone a snippet to your computer for local editing. Learn more.