File Coverage

blib/lib/PAGI/Context/SSE.pm
Criterion Covered Total %
statement 31 32 96.8
branch n/a
condition 2 3 66.6
subroutine 24 25 96.0
pod 22 23 95.6
total 79 83 95.1


line stmt bran cond sub pod time code
1             package PAGI::Context::SSE;
2              
3 18     18   117 use strict;
  18         26  
  18         612  
4 18     18   66 use warnings;
  18         25  
  18         10606  
5              
6             our @ISA = ('PAGI::Context');
7              
8             # ── Underlying PAGI::SSE accessor ────────────────────────────────────
9              
10             sub sse {
11 50     50 0 108 my ($self) = @_;
12 50   66     154 return $self->{_sse} //= do {
13 31         3495 require PAGI::SSE;
14 31         131 PAGI::SSE->new($self->{scope}, $self->{receive}, $self->{send});
15             };
16             }
17              
18             # ── Connection lifecycle ─────────────────────────────────────────────
19              
20 10     10 1 86 sub start { shift->sse->start(@_) }
21 2     2 1 92 sub close { shift->sse->close(@_) }
22              
23             # ── Send methods ─────────────────────────────────────────────────────
24              
25 1     1 1 11 sub send { shift->sse->send(@_) }
26 3     3 1 22 sub send_json { shift->sse->send_json(@_) }
27 1     1 1 13 sub send_event { shift->sse->send_event(@_) }
28 1     1 1 27 sub send_comment { shift->sse->send_comment(@_) }
29              
30 1     1 1 26 sub try_send { shift->sse->try_send(@_) }
31 1     1 1 27 sub try_send_json { shift->sse->try_send_json(@_) }
32 1     1 1 26 sub try_send_comment { shift->sse->try_send_comment(@_) }
33 1     1 1 26 sub try_send_event { shift->sse->try_send_event(@_) }
34              
35             # ── Iteration helpers ────────────────────────────────────────────────
36              
37 1     1 1 20 sub each { shift->sse->each(@_) }
38 0     0 1 0 sub every { shift->sse->every(@_) }
39              
40             # ── State inspection ─────────────────────────────────────────────────
41              
42 2     2 1 53 sub is_started { shift->sse->is_started }
43 3     3 1 15 sub is_closed { shift->sse->is_closed }
44              
45             # ── Protocol metadata ────────────────────────────────────────────────
46              
47 1     1 1 8 sub last_event_id { shift->sse->last_event_id }
48 1     1 1 8 sub http_version { shift->sse->http_version }
49 1     1 1 11 sub keepalive { shift->sse->keepalive(@_) }
50              
51             # ── Query parameter accessors ────────────────────────────────────────
52             # SSE uses query_param (singular) vs WebSocket's query (method name
53             # mirrors what PAGI::SSE exposes).
54              
55 3     3 1 623 sub query_param { shift->sse->query_param(@_) }
56 1     1 1 8 sub query_params { shift->sse->query_params(@_) }
57 1     1 1 8 sub raw_query_param { shift->sse->raw_query_param(@_) }
58 1     1 1 8 sub raw_query_params { shift->sse->raw_query_params(@_) }
59              
60             # ── Header extras ────────────────────────────────────────────────────
61              
62 1     1 1 8 sub header_all { shift->sse->header_all(@_) }
63              
64             1;
65              
66             __END__