Sign in to PrePAN


User's Modules

Plack::App::URLMux PSGI/Plack component for dispatching multiple applications based on URL path and patterns

The module is designed for multiplexing applications by URL path and patterns. This module is based on Plack::App::URLMap, but it optimized to dispatching a lot of URLs without performance regression. Additionally this module provide the ability to assign routing rules using URL patterns with named parameters. The format of parameter consist of ':' followed by parameter name and quantifier which is the same as for regexp expressions.

The idea was in that URL in RFC1738 for HTTP defined as hierarchical resource locator with '/' as delimeter and the package splits url-path on this parts, searches the application by them in mapped search tree and fills the matched named patters. This module defines value of a named parameter as one o more parts of the url-path (hsegment in RFC terms) in array context and returns list of matched parameters in PSGI/Plack environment 'plack.urlmux,params.url' as array of name and value pairs.

The namespace for Plack additional modules can be used for components as Plack::App and for middleware as Plack::Middleware, so I have chosen the Plack::App::URLMux name. I send a email to author of Plack modules about naming the module and did not receive feedback, so I decide to write about the package here.

I don`t like the idea to implement a URL multiplexer as regexp expression URL parser as in (Python dispatcher)[] for example, due its performance issues for a lot of URL rules. This module solves the performance problem by simplify the regexp expressions to named patterns and operates more larger constructions - url-path segments.

Any suggestions, comments and criticism are welcome.

AlexBurnes@github 0 comments