lib/Mojolicious/Plugin/CBOR.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 21 / 21 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
register
1.0
CRAP 1.0
↑ Summary
1 package Mojolicious::Plugin::CBOR;
2  
3 1 ▶use Mojo::Base 'Mojolicious::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use CBOR::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '0.04';
7  
8 sub register
9 1 ▶{
Subroutine register: called CC=1 SCAR=0.0
Pod documented
10 1 my ($self, $app, $args) = @_;
11  
12 1 $app->types->type(cbor => 'application/cbor; charset=UTF-8');
13
14 1 ▶ $app->renderer->add_handler(cbor => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
15 1 my ($renderer, $c, $output, $options) = @_;
16
17 # force disabling Mojo encoding
18 1 delete $options->{'encoding'};
19  
20 1 $options->{'format'} = 'cbor';
21  
22 1 my $cbor = CBOR::XS->new();
23
24 1 $$output = $cbor->encode($c->stash->{'cbor'});
25 1 });
26 }
27  
28 1 1;
29  
30 __END__
↑ Summary