blib/lib/Dancer/Plugin/EmptyGIF.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 20 / 20 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 package Dancer::Plugin::EmptyGIF;
2  
3 =head1 NAME
4  
5 Dancer::Plugin::EmptyGIF - Quick empty GIF response
6  
7 =head1 SYNOPSIS
8  
9 use Dancer;
10 use Dancer::Plugin::EmptyGIF;
11
12 get '/tracking/pixel.gif' => sub {
13 # do something with params
14 return empty_gif;
15 }
16  
17 =head1 METHODS
18  
19 =head2 empty_gif
20  
21 This will set your set your current request response to be an empty
22 gif, this means, it will return binary data for the image and
23 set the appropriate headers. You should always "return empty_gif".
24  
25 =head1 WHY
26  
27 An empty gif response is specially useful when you're building a
28 webservice that processes all the URL and/or query string parameters
29 and at the end, an empty gif needs to be returned to the client.
30 This a tracking or reporting pixel. Once the request has reached your
31 application code, it's better not to do any more redirections and
32 quickly return the empty pixel from within your code.
33  
34 =head1 AUTHOR
35  
36 David Moreno C<< <david at axiombox dot com> >>
37  
38 =head1 CODE
39  
40 L<http://github.com/damog/Dancer-Plugin-EmptyGIF>
41  
42 =head1 LICENSE
43  
44 Copyright, David Moreno, 2012
45  
46 This program is free software; you can redistribute it
47 and/or modify it under the same terms as Perl itself.
48  
49 =cut
50  
51 4 ▶use Dancer ':syntax';
Subroutine BEGIN: called CC=1 SCAR=0.0
52 4 ▶use Dancer::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 4 ▶use MIME::Base64;
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 4 our $VERSION = '0.3';
56  
57 4 ▶register empty_gif => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
58 4 header('Content-Type' => 'image/gif');
59 4 header('Content-Disposition' => 'inline; filename="empty.gif"');
60 4 decode_base64('R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
61 4 };
62  
63 4 register_plugin;
64 4 1;
↑ Summary