-
-
10 Aug 2014 18:12:54 UTC
- Distribution: PAD
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (1)
- Testers (409 / 10 / 1)
- Kwalitee
Bus factor: 0- 43.40% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (25.73KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
++ed by:3 non-PAUSE users- Dependencies
- Plack::App::Directory
- Plack::App::File
- Plack::Request
- Plack::Runner
- Pod::Usage
- Text::Markdown
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
PAD::Plugin - base class for writing pad plugin
SYNOPSIS
package PAD::Plugin::Static; use parent 'PAD::Plugin'; use Plack::App::File; sub execute { my $self = shift; Plack::App::Directory->new->to_app->($self->request->env); }
METHODS
suffix
-
Specifies the suffix of file (in regexp) that to be filtered.
# e.g.) for markdown file, sub suffix { qr/\.md$/ }
content_type
-
Defines Content-Type of response. Default is
text/plain; charset=UTF-8
.# e.g.) serve HTML file, sub content_type { 'text/html; charset=UTF-8' }
request
-
Accessor of the
Plack::Request
. You can call this method inexecute
method. relative_path
-
Converts
PATH_INFO
into relative path. This method is convenient foropen
ing file. execute
-
Write the main logic here.
# e.g.) renders a markdown document and returns C<finalized> PSGI response sub execute { my $self = shift; my $path = $self->relative_path; open my $text, '<', $path or die $!; my $md = markdown(do { local $/; <$text> }); my $res = $self->request->new_response(200, ['Content-Type' => $self->content_type], $md); $res->finalize; }
AUTHOR
punytan <punytan@gmail.com>
SEE ALSO
PAD, PAD::Plugin::Static, PAD::Plugin::Markdown
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install PAD, copy and paste the appropriate command in to your terminal.
cpanm PAD
perl -MCPAN -e shell install PAD
For more information on module installation, please visit the detailed CPAN module installation guide.