blib/lib/PAGI/Nano/Context/SSE.pm

filter: Statementstmt 100% 22 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 100% 30 / 30 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« examples/mini-framework/app.pl ↑ Summary blib/lib/PAGI/Nano/Context/WebSocket.pm »
1 package PAGI::Nano::Context::SSE;
2 11 $PAGI::Nano::Context::SSE::VERSION = '0.001001';
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use parent -norequire, 'PAGI::Context::SSE', 'PAGI::Nano::Context';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use PAGI::Context; # base declares @ISA but does not load it
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use PAGI::Context::SSE;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use PAGI::Nano::Context; # the shared mixin (uri_for)
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # The SSE context Nano vends: a genuine PAGI::Context::SSE (so $c->sse and the
11 # rest of the SSE API work) plus the shared Nano behavior, notably $c->uri_for
12 # for building links from SSE handlers. Blessed directly so the base factory's
13 # scope-type resolution does not down-cast us.
14  
15 8 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
16 8 my ($class, $scope, $receive, $send) = @_;
17 8 return bless {
18 scope => $scope,
19 receive => $receive,
20 send => $send,
21 }, $class;
22 }
23  
24 11 1;
25  
26 =encoding utf8
27  
28 =head1 NAME
29  
30 PAGI::Nano::Context::SSE - The SSE context vended by PAGI::Nano
31  
32 =head1 DESCRIPTION
33  
34 A subclass of L<PAGI::Context::SSE> (so C<< $c->sse >> and the full SSE API are
35 available) that also mixes in L<PAGI::Nano::Context>, giving SSE handlers
36 C<< $c->uri_for >> for link generation.
37  
38 =head1 METHODS
39  
40 =head2 raw_send
41  
42 my $send = $c->raw_send;
43 await $send->({ type => 'sse.send', ... });
44  
45 The raw PAGI C<$send> coderef for this connection, inherited from
46 L<PAGI::Context/raw_send>. On the SSE context this matters: C<< $c->send >> is
47 overridden with the C<sse.send> convenience, so a handler that needs to emit a
48 custom event type (or otherwise speak the channel protocol directly) reaches for
49 C<raw_send> to bypass the override. See F<examples/custom-send-events> for a
50 content-negotiated SSE/NDJSON renderer built on it.
51  
52 =head1 SEE ALSO
53  
54 L<PAGI::Nano>, L<PAGI::Nano::Context>, L<PAGI::Context::SSE>.
55  
56 =head1 AUTHOR
57  
58 John Napiorkowski C<< <jjnapiork@cpan.org> >>
59  
60 =head1 COPYRIGHT & LICENSE
61  
62 Copyright 2026, John Napiorkowski. This library is free software; you can
63 redistribute it and/or modify it under the same terms as Perl itself.
64  
65 =cut
« examples/mini-framework/app.pl ↑ Summary blib/lib/PAGI/Nano/Context/WebSocket.pm »