blib/lib/PAGI/Middleware/Session/State.pm

filter: Statementstmt 100% 15 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 4 / 4 totaltotal 100% 25 / 25 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
new
1.0
CRAP 1.0
« blib/lib/PAGI/Context/WebSocket.pm ↑ Summary blib/lib/PAGI/Middleware/Session/Store.pm »
1 package PAGI::Middleware::Session::State;
2 5 $PAGI::Middleware::Session::State::VERSION = '0.002002';
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 PAGI::Middleware::Session::State - Base class for session state extraction
9  
10 =head1 SYNOPSIS
11  
12 package My::State;
13 use parent 'PAGI::Middleware::Session::State';
14  
15 sub extract {
16 my ($self, $scope) = @_;
17 # Return session ID or undef
18 }
19  
20 sub inject {
21 my ($self, $headers, $id, $options) = @_;
22 # Push response header onto @$headers
23 }
24  
25 =head1 DESCRIPTION
26  
27 PAGI::Middleware::Session::State defines the interface for session ID
28 transport. Subclasses determine how the session ID is extracted from
29 incoming requests and injected into outgoing responses.
30  
31 =head1 METHODS
32  
33 =head2 new
34  
35 my $state = PAGI::Middleware::Session::State->new(%options);
36  
37 Create a new state handler.
38  
39 =cut
40  
41 59 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
42 59 my ($class, %options) = @_;
43  
44 59 return bless { %options }, $class;
45 }
46  
47 =head2 extract
48  
49 my $session_id = $state->extract($scope);
50  
51 Extract the session ID from the PAGI scope. Returns the session ID
52 string or undef if none is found. Subclasses must implement this.
53  
54 =cut
55  
56 1 ▶sub extract {
Subroutine extract: called CC=1 SCAR=0.0
Pod documented
57 1 my ($self, $scope) = @_;
58  
59 1 die ref($self) . " must implement extract()";
60 }
61  
62 =head2 inject
63  
64 $state->inject(\@headers, $id, \%options);
65  
66 Inject the session ID into the response by pushing header arrayrefs
67 onto the provided headers array. Subclasses must implement this.
68  
69 =cut
70  
71 1 ▶sub inject {
Subroutine inject: called CC=1 SCAR=0.0
Pod documented
72 1 my ($self, $headers, $id, $options) = @_;
73  
74 1 die ref($self) . " must implement inject()";
75 }
76  
77 =head2 clear
78  
79 $state->clear(\@headers);
80  
81 Clear the client-side session state (e.g., expire a cookie). Called
82 when a session is destroyed. The default implementation is a no-op,
83 suitable for state handlers where the client manages transport
84 (Header, Bearer). Cookie-based state handlers should override this
85 to emit an expired Set-Cookie header.
86  
87 =cut
88  
89 1 ▶sub clear {
Subroutine clear: called CC=1 SCAR=0.0
Pod documented
90 1 my ($self, $headers) = @_;
91 # Default: no-op (Header/Bearer don't need to clear anything)
92 }
93  
94 5 1;
95  
96 __END__
« blib/lib/PAGI/Context/WebSocket.pm ↑ Summary blib/lib/PAGI/Middleware/Session/Store.pm »