NAME
PAGI::Middleware::Session::State::Header - Header-based session ID transport
SYNOPSIS
use PAGI::Middleware::Session::State::Header;
my $state = PAGI::Middleware::Session::State::Header->new(
header_name => 'X-Session-ID',
);
# With extraction pattern
my $state = PAGI::Middleware::Session::State::Header->new(
header_name => 'X-Auth-Token',
pattern => qr/^Token\s+(.+)$/i,
);
# Extract session ID from request
my $id = $state->extract($scope);
DESCRIPTION
Implements the PAGI::Middleware::Session::State interface using a custom HTTP header for session ID transport. The session ID is read from the specified request header. Injection is a no-op because the client is responsible for managing header-based transport.
CONFIGURATION
header_name (required)
Name of the HTTP header containing the session ID.
pattern (optional)
A regex with a capture group to extract the session ID from the header value. If not provided, the full header value is used as the session ID.
extract
my $session_id = $state->extract($scope);
Find the configured header in $scope->{headers} (case-insensitive) and return its value as the session ID. If a pattern is configured, apply it and return the first capture group. Returns undef if the header is not found or the pattern does not match.
inject
$state->inject(\@headers, $id, \%options);
No-op. Header-based session transport is managed by the client, so the server does not inject any response headers.
SEE ALSO
PAGI::Middleware::Session::State - Base state interface
PAGI::Middleware::Session::State::Bearer - Bearer token shortcut
PAGI::Middleware::Session - Session management middleware