I have two routes
One under 'under' which does the authentication from 'userinfo' and another one which is meant for public
post '/public' => sub {
my $c = shift;
my $submitter = $c->param('submitter');
my $password = $c->param('password');
my $url = Mojo::URL->new('/v1/time')->userinfo("$submitter:$password");
$c->redirect_to( $url );
};
under(sub {
my $c = shift;
$c->app->log->debug( Dumper($c->req->url) );
my ($un, $pw) = split ':', $c->req->url->to_abs->userinfo;
# do authentication here
# .....
});
any ['GET', 'POST'] => '/v1/time' => sub {
shift->render(json => { now => scalar(localtime) });
};
Why I can't seem to pass the userinfo data to the new url?
Result from Data::Dumper is
bless( {
'base' => bless( {
'scheme' => 'http',
'port' => 'xxxxx',
'host' => 'xxxxxxxxx.corpnet2.com'
}, 'Mojo::URL' ),
'query' => bless( {
'pairs' => []
}, 'Mojo::Parameters' ),
'path' => bless( {
'charset' => 'UTF-8',
'path' => '/v1/time'
}, 'Mojo::Path' )
}, 'Mojo::URL' );
Joel had answered this actually..
https://github.com/mojolicious/mojo/wiki/Upgrading#mojourl-authority-and-userinfo https://github.com/mojolicious/mojo/issues/1006