NAME
Plack::App::Directory::PYX - Plack PYX directory application.
SYNOPSIS
my
$obj
= Plack::App::Directory::PYX->new(
%parameters
);
my
$psgi_ar
=
$obj
->serve_path(
$env
,
$path_to_file_or_dir
);
my
$app
=
$obj
->to_app;
METHODS
new
my
$obj
= Plack::App::Directory::PYX->new(
%parameters
);
Constructor.
Returns instance of object.
indent
Set Tags::Output::* class for output serialization.
Default value is Tags::Output::Raw.
serve_path
my
$psgi_ar
=
$obj
->serve_path(
$env
,
$path_to_file_or_dir
);
Process file or directory on disk and serve it to application.
Returns reference to array (PSGI structure).
to_app
my
$app
=
$obj
->to_app;
Creates Plack application.
Returns Plack::Component object.
EXAMPLE1
use
strict;
use
warnings;
use
File::Temp;
use
IO::Barf;
use
Plack::Runner;
# Temporary file with PYX.
my
$temp_pyx_file
= File::Temp->new->filename;
# PYX file.
my
$pyx
=
<<'END';
(html
(head
(title
-Title
)title
)head
(body
(div
-Hello world
)div
)body
)html
END
barf(
$temp_pyx_file
,
$pyx
);
# Run application with one PYX file.
my
$app
= Plack::App::Directory::PYX->new(
'file'
=>
$temp_pyx_file
)->to_app;
Plack::Runner->new->run(
$app
);
# Output:
# HTTP::Server::PSGI: Accepting connections at http://0:5000/
# > curl http://localhost:5000/
# <html><head><title>Title</title></head><body><div>Hello world</div></body></html>
EXAMPLE2
use
strict;
use
warnings;
use
File::Temp;
use
IO::Barf;
use
Plack::Runner;
# Temporary file with PYX.
my
$temp_pyx_file
= File::Temp->new->filename;
# PYX file.
my
$pyx
=
<<'END';
(html
(head
(title
-Title
)title
)head
(body
(div
-Hello world
)div
)body
)html
END
barf(
$temp_pyx_file
,
$pyx
);
# Run application with one PYX file.
my
$app
= Plack::App::Directory::PYX->new(
'file'
=>
$temp_pyx_file
,
'indent'
=>
'Tags::Output::Indent'
,
)->to_app;
Plack::Runner->new->run(
$app
);
# Output:
# HTTP::Server::PSGI: Accepting connections at http://0:5000/
# > curl http://localhost:5000/
# <html>
# <head>
# <title>
# Title
# </title>
# </head>
# <body>
# <div>
# Hello world
# </div>
# </body>
# </html>
DEPENDENCIES
English, Error::Pure, Plack::App::Directory, Plack::Util::Accessor, PYX::SGML::Tags, Tags::Output::Raw, Unicode::UTF8,
REPOSITORY
https://github.com/michal-josef-spacek/Plack-App-Directory-PYX
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2016-2022 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.05