| 1 | ## no critic (RequireUseStrict) | ||||||||||
| 2 | package Plack::Middleware::Acme::YadaYada; | ||||||||||
| 3 | 2 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | $Plack::Middleware::Acme::YadaYada::VERSION = '0.01'; | |||||||||
| 5 | } | ||||||||||
| 6 | |||||||||||
| 7 | ## use critic (RequireUseStrict) | ||||||||||
| 8 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | use parent 'Plack::Middleware'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 2 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 2 | ▶ | sub call { | ||||||||
|
Subroutine
call: called CC=1 SCAR=0.1
Pod
documented
| |||||||||||
| 16 | 2 | my ( $self, $env ) = @_; | |||||||||
| 17 | |||||||||||
| 18 | 2 | my $app = $self->app; | |||||||||
| 19 | 2 | my $retval; | |||||||||
| 20 | |||||||||||
| 21 | 2 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 2 | $retval = $app->($env); | |||||||||
| 23 | 1 | ▶ | } catch { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.1
| |||||||||||
| 24 | 1 | ▶ | if(/^Unimplemented/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 1 | $retval = [ | |||||||||
| 26 | 501, | ||||||||||
| 27 | ['Content-Type' => 'text/plain'], | ||||||||||
| 28 | ['Not Implemented'], | ||||||||||
| 29 | ]; | ||||||||||
| 30 | } else { | ||||||||||
| 31 | 0 | die; | |||||||||
| 32 | } | ||||||||||
| 33 | 2 | }; | |||||||||
| 34 | |||||||||||
| 35 | 2 | return $retval; | |||||||||
| 36 | }; | ||||||||||
| 37 | |||||||||||
| 38 | 2 | 1; | |||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | =pod | ||||||||||
| 43 | |||||||||||
| 44 | =head1 NAME | ||||||||||
| 45 | |||||||||||
| 46 | Plack::Middleware::Acme::YadaYada - Middleware that handles the Yada Yada operator | ||||||||||
| 47 | |||||||||||
| 48 | =head1 VERSION | ||||||||||
| 49 | |||||||||||
| 50 | version 0.01 | ||||||||||
| 51 | |||||||||||
| 52 | =head1 SYNOPSIS | ||||||||||
| 53 | |||||||||||
| 54 | use Plack::Builder; | ||||||||||
| 55 | |||||||||||
| 56 | my $app = sub { ... }; | ||||||||||
| 57 | |||||||||||
| 58 | builder { | ||||||||||
| 59 | enable 'Acme::YadaYada'; | ||||||||||
| 60 | $app; | ||||||||||
| 61 | }; | ||||||||||
| 62 | |||||||||||
| 63 | =head1 DESCRIPTION | ||||||||||
| 64 | |||||||||||
| 65 | This middleware handles exceptions thrown by the Yada Yada operator and | ||||||||||
| 66 | returns "501 Not Implemented" if it encounters any. | ||||||||||
| 67 | |||||||||||
| 68 | =head1 SEE ALSO | ||||||||||
| 69 | |||||||||||
| 70 | L<perlop/Yada_Yada_Operator>, L<Plack::Middleware> | ||||||||||
| 71 | |||||||||||
| 72 | =head1 AUTHOR | ||||||||||
| 73 | |||||||||||
| 74 | Rob Hoelz <rob@hoelz.ro> | ||||||||||
| 75 | |||||||||||
| 76 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 77 | |||||||||||
| 78 | This software is copyright (c) 2011 by Rob Hoelz. | ||||||||||
| 79 | |||||||||||
| 80 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 81 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 82 | |||||||||||
| 83 | =head1 BUGS | ||||||||||
| 84 | |||||||||||
| 85 | Please report any bugs or feature requests on the bugtracker website | ||||||||||
| 86 | http://github.com/hoelzro/plack-middleware-acme-yadayada/issues | ||||||||||
| 87 | |||||||||||
| 88 | When submitting a bug or request, please include a test-file or a | ||||||||||
| 89 | patch to an existing test-file that illustrates the bug or desired | ||||||||||
| 90 | feature. | ||||||||||
| 91 | |||||||||||
| 92 | =cut | ||||||||||
| 93 | |||||||||||
| 94 | |||||||||||
| 95 | __END__ | ||||||||||