JSONFactory.pm

filter: Statementstmt 100% 12 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 17 / 17 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Role/JSONBody.pm ↑ Summary
1 package HTTP::Throwable::JSONFactory;
2 # ABSTRACT: Throw exceptions with JSON bodies
3 1 $HTTP::Throwable::JSONFactory::VERSION = '0.001';
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use parent qw(HTTP::Throwable::Factory);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub extra_roles {
10 1 ▶ return qw(
Subroutine extra_roles: called CC=1 SCAR=0.0
Pod documented
11 HTTP::Throwable::Role::JSONBody
12 );
13 }
14  
15 1 1;
16  
17 =pod
18  
19 =encoding UTF-8
20  
21 =head1 NAME
22  
23 HTTP::Throwable::JSONFactory - Throw exceptions with JSON bodies
24  
25 =head1 VERSION
26  
27 version 0.001
28  
29 =head1 SYNOPSIS
30  
31 use HTTP::Throwable::JSONFactory qw(http_throw);
32  
33 http_throw(Gone => {
34 payload => {
35 error => "You won't find what you're looking for here",
36 },
37 });
38  
39 =head1 OVERVIEW
40  
41 This subclass of L<HTTP::Throwable::Factory> arranges for each built/thrown
42 exception to consume the L<HTTP::Throwable::Role::JSONBody> role, which
43 will generate HTTP responses with an C<application/json> content type and
44 encode the provided payload using L<JSON::MaybeXS>.
45  
46 The C<payload> attribute passed to C<http_throw> or C<http_exception> should
47 be anything allowed by L<JSON/encode_json> (hashref, arrayref, etc).
48  
49 =head1 AUTHOR
50  
51 Matthew Horsfall <wolfsage@gmail.com>
52  
53 =head1 COPYRIGHT AND LICENSE
54  
55 This software is copyright (c) 2016 by Matthew Horsfall.
56  
57 This is free software; you can redistribute it and/or modify it under
58 the same terms as the Perl 5 programming language system itself.
59  
60 =cut
61  
62 __END__
« Role/JSONBody.pm ↑ Summary