我有两条路线
在'under'下的一个用于从'userinfo'进行身份验证,而另一个则是用于公共的
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) });
};
为什么我似乎无法将userinfo数据传递给新的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' );
答案 0 :(得分:0)