File: PoweredBy.pm

package info (click to toggle)
libmojolicious-perl 0.999926-1%2Bsqueeze2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,672 kB
  • ctags: 949
  • sloc: perl: 17,391; makefile: 4
file content (68 lines) | stat: -rw-r--r-- 1,584 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright (C) 2008-2010, Sebastian Riedel.

package Mojolicious::Plugin::PoweredBy;

use strict;
use warnings;

use base 'Mojolicious::Plugin';

# It's just like the story of the grasshopper and the octopus.
# All year long, the grasshopper kept burying acorns for the winter,
# while the octopus mooched off his girlfriend and watched TV.
# But then the winter came, and the grasshopper died,
# and the octopus ate all his acorns.
# And also he got a racecar. Is any of this getting through to you?
sub register {
    my ($self, $app, $args) = @_;

    # Name
    my $name = $args->{name} || 'Mojolicious (Perl)';

    # Add header
    $app->plugins->add_hook(
        after_build_tx => sub {
            my ($self, $tx) = @_;
            $tx->res->headers->header('X-Powered-By' => $name);
        }
    );
}

1;
__END__

=head1 NAME

Mojolicious::Plugin::PoweredBy - Powered By Plugin

=head1 SYNOPSIS

    # Mojolicious
    $self->plugin('powered_by');
    $self->plugin(powered_by => (name => 'MyApp 1.0'));

    # Mojolicious::Lite
    plugin 'powered_by';
    plugin powered_by => (name => 'MyApp 1.0');

=head1 DESCRIPTION

L<Mojolicous::Plugin::PoweredBy> is a plugin that adds an C<X-Powered-By>
header which defaults to C<Mojolicious (Perl)>.

=head1 METHODS

L<Mojolicious::Plugin::PoweredBy> inherits all methods from
L<Mojolicious::Plugin> and implements the following new ones.

=head2 C<register>

    $plugin->register;

Register plugin hooks in L<Mojolicious> application.

=head1 SEE ALSO

L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>.

=cut