我有一个基于 Starman 的服务器 -
#!/usr/bin/perl
use strict;
use warnings;
use Data::Printer;
use Plack::Builder;
my $app = sub {
my $env = shift;
my $session = $env->{'psgix.session'};
# Print environment variables
p($env);
return [
200,
[ 'Content-Type' => 'text/plain' ],
[ "Hello, you've been here for ", $session->{counter}++, "th time!" ],
];
};
my $default = sub {
my $env = shift;
p($env);
return [
'200', [ 'Content-Type' => 'text/html' ],
["Welcome to default page"],
];
};
builder {
mount "/validate" => builder {
enable "Middleware::Authentication"
enable "Session";
$app;
};
mount "/" => builder { $default };
};
我自己的中间件“身份验证”对用户进行身份验证并返回会话信息(到期时间、会话密钥等)用于会话管理,那么我如何在会话中间件中使用这些信息?