NAME

Nile::Dispatcher - Application action dispatcher.

SYNOPSIS

# dispatch the default route or detect route from request
$app->dispatcher->dispatch;

# dispatch specific route and request method
$app->dispatcher->dispatch($route, $request_method);
$app->dispatcher->dispatch('/accounts/register/create');
$app->dispatcher->dispatch('/accounts/register/save', 'POST');

DESCRIPTION

Nile::Dispatcher - Application action dispatcher.

dispatch()

# dispatch the default route or detect route from request
$app->dispatcher->dispatch;

# dispatch specific route and request method
$app->dispatcher->dispatch($route, $request_method);

Process the action and send output to client.

dispatch_action()

# dispatch the default route or detect route from request
$content = $app->dispatcher->dispatch_action;

# dispatch specific route and request method
$content = $app->dispatcher->dispatch_action($route, $request_method);

Process the action and return output.

action()

my ($module, $controller, $action) = $app->dispatcher->action($route);
#route /module/controller/action returns (Module, Controller, action)
#route /module/action returns (Module, Module, action)
#route /module returns (Module, Module, index)

Find the action module, controller and method name from the provided route.

route()

my $route = $app->dispatcher->route($route);

Detects the current request path if not provided from the request params named as 'action', 'route', or 'cmd' in the post or get methods:

# uri route
/blog/?action=register

# form route
<input type="hidden" name="action" value="register" />

If not found, it will try to detect the route from the request uri after the path part

# assuming application path is /blog, so /register will be the route
/blog/register

Bugs

This project is available on github at https://github.com/mewsoft/Nile.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Nile.

SOURCE

Source repository is at https://github.com/mewsoft/Nile.

SEE ALSO

See Nile for details about the complete framework.

AUTHOR

Ahmed Amin Elsheshtawy, احمد امين الششتاوى <mewsoft@cpan.org> Website: http://www.mewsoft.com

COPYRIGHT AND LICENSE

Copyright (C) 2014-2015 by Dr. Ahmed Amin Elsheshtawy احمد امين الششتاوى mewsoft@cpan.org, support@mewsoft.com, https://github.com/mewsoft/Nile, http://www.mewsoft.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.