Nephia::Core - Core Class of Nephia
Core Class of Nephia, Object Oriented Interface Included.
my $v = Nephia::Core->new( appname => 'YourApp::Web', plugins => ['JSON', 'HashHandler' => { ... } ], ); $v->app(sub { my $req = req(); [200, [], 'Hello, World']; }); $v->run;
Your Application Name. Default is caller class.
Nephia plugins you want to load.
Application as coderef.
Returns a Nephia::Chain object for specifying order of actions.
Returns a Nephia::Chain object for specifying order of filters.
Returns a Nephia::Chain object for specifying order of builders.
Returns caller class name as string.
Accessor method for application coderef (ignore plugins, actions, filters, and builders).
Export DSL (see dsl method) into caller namespace.
Returns objects of loaded plugins.
Returns pairs of name and coderef of DSL as hashref.
Returns an application as coderef (include plugins, actions, filters, and builders).
If you specify some arguments, these will be stored as config into context.
Look at following example. This psgi application returns 'Nephia is so good!'.
my $v = Nephia::Core->new( app => sub { my $c = shift; [200, ['Content-Type' => 'text/plain'], ['Nephia is '.$c->{config}{message}]]; }, ); $v->run(message => 'so good!');
Nephia::Core includes hook mechanism itself. These provided as Nephia::Chain object.
Nephia::Core has action_chain, filter_chain, and builder_chain.
First, Look following ASCII Art Image.
This AA presents relation of builder chain and application.
/----------------------------------------------\ | | | /---------------\ | | | | | | | /~\ /~\ | | | | |B| |B| | | | +---------------+ | |u| |u| | | |\ +----------+ | | | | |i| |i| | | | \ | | | | +---------------|l|---|l|------------+ \ | | | | $v->run; | application |d| |d| \| PSGI | | | | |e| |e| > | | | +---------------|r|---|r|------------+ /| App. | | | | | | | | | | | | / | | | +---------------+ | |1| |2| | | | / | | | | \_/ \_/ | | |/ +----------+ | $v | | | | Nephia::Core obj. | builder_chain | | | \---------------/ | \----------------------------------------------/
When execute run method of Nephia::Core instance, run method returns PSGI Application (coderef).
Then, Builders in builder_chain modifies PSGI Application.
Okay. Look following ASCII Art Image.
This AA presents relation of request, response, action chain, and filter chain.
[HTTP Request] [HTTP Response] | A /-------|---------------------------------------------------|--------------\ | | Your Application | | | | | | | v | | | /------------------------------------\ /---------------------\ | | | | | | | | | Nephia::Context |--->| Nephia::Response | | | | | | | | | \------------------------------------/ \---------------------/ | | | A | A | A | A | A | | | | | | | | | | [Content] | | | /---|--|----|--|-----|---|----|--|--\ /----|-----------|--------\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | v | v | v | v | | | v | | | | | /~\ | /~\ | /~~~\ | /~\ | | | /~\ /~\ | | | | | |A| | |A| | | A | | |A| | | | |F| |F| | | | | | |c|-/ |c|-/ | p |-/ |c|-/ | | |i|--->|i|---+ | | | | |t| |t| | p.| |t| | | |l| |l| | | | | |i| |i| | | |i| | | |t| |t| | | | | |o| |o| \---/ |o| | | |e| |e| | | | | |n| |n| |n| | | |r| |r| | | | | | | | | | | | | | | | | | | | | |1| |2| |3| | | |1| |2| | | | | \_/ \_/ \_/ | | \_/ \_/ | | | | | | | | | | action_chain | | filter_chain | | | \-----------------------------------/ \-------------------------/ | \--------------------------------------------------------------------------/
Actions (and App) in action_chain affects context. Then, Nephia::Response object creates from context.
Afterwords, filters in filter_chain affects content string in Nephia::Response.
ytnobody <ytnobody@gmail.com>
Nephia::Chain
To install Nephia, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Nephia
CPAN shell
perl -MCPAN -e shell install Nephia
For more information on module installation, please visit the detailed CPAN module installation guide.