UR::Service::UrlRouter(3pm) | User Contributed Perl Documentation | UR::Service::UrlRouter(3pm) |
UR::Service::UrlRouter - PSGI-aware router for incoming requests
my $r = UR::Service::UrlRouter->create(); $r->GET('/index.html', \&handle_index); $r->POST(qr(update/(.*?).html, \&handle_update); my $s = UR::Service::WebServer->create(); $s->run( $r );
This class acts as a middleman, routing requests from a PSGI server to the appropriate function to handle the requests.
$handler is a CODE ref. When called, the first argument is the standard PSGI env hashref.
This class overloads the function dereference (call) operator so that the object may be used as a callable object (ie. $obj->(arg, arg)). As overload expects, __call__ returns a code ref that handles the PSGI request by finding an appropriate match with the incoming request and a previously registered handler. If no matching handler is found, it returns a 404 error code.
If multiple handlers match the incoming request, then only the earliest registered handler will be called.
UR::Service::WebServer, HTTP::Server::PSGI, Plack
2022-01-17 | perl v5.32.1 |