Mojolicious 使用用户信息重定向到 'under' 下的不同路径
Mojolicious redirect to different path under 'under' with userinfo
我有两条路线
'under' 下的一个从 'userinfo' 进行身份验证,另一个用于 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) });
};
为什么我似乎无法将用户信息数据传递给新 url?
Data::Dumper 的结果是
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' );
我有两条路线
'under' 下的一个从 'userinfo' 进行身份验证,另一个用于 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) });
};
为什么我似乎无法将用户信息数据传递给新 url?
Data::Dumper 的结果是
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' );