Snippets

Brian Medley RoaB7: Untitled snippet

Created by Brian Medley last modified
package Mojolicious::Plugin::DataExample;

use Mojo::Base 'Mojolicious::Plugin';

our $VERSION = '0.01';

sub register {
    my ($self, $app) = @_;

    $app->log->debug("Hello");
}

1;

__DATA__

@@ test.txt (base64)
dGVzdCAxMjMKbGFsYWxh

__END__

=encoding utf8

=head1 NAME

Mojolicious::Plugin::DataExample - Mojolicious Plugin

=cut
#!/opt/perl

use Mojolicious::Lite;

use Mojo::Loader qw(data_section);

plugin 'DataExample';

get '/' => sub {
    my $c = shift;

    my $text = data_section('Mojolicious::Plugin::DataExample', 'test.txt');

    $c->render(text => $text);
};

app->start;
1
2
3
4
5
6
7
8
[bpm@bmedley] c:~/playground>/opt/perl -IMojolicious-Plugin-DataExample/lib  data_example.pl get /   
[Fri Sep 25 23:09:13 2015] [debug] Hello
[Fri Sep 25 23:09:13 2015] [debug] Your secret passphrase needs to be changed
[Fri Sep 25 23:09:13 2015] [debug] GET "/"
[Fri Sep 25 23:09:13 2015] [debug] Routing to a callback
[Fri Sep 25 23:09:13 2015] [debug] 200 OK (0.001079s, 926.784/s)
test 123
lalala%                                                                                                                                                                             [bpm@bmedley] c:~/playground>

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.