{"id":20550302,"url":"https://github.com/dnmfarrell/router-xs","last_synced_at":"2026-04-20T01:35:14.792Z","repository":{"id":149704038,"uuid":"92419474","full_name":"dnmfarrell/Router-XS","owner":"dnmfarrell","description":"Fast URI path to value lookup","archived":false,"fork":false,"pushed_at":"2017-05-31T12:56:00.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-16T16:49:39.941Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dnmfarrell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-25T15:51:15.000Z","updated_at":"2017-05-25T15:53:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"e97c852a-0507-4333-aaae-53a27aac0f5a","html_url":"https://github.com/dnmfarrell/Router-XS","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2FRouter-XS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2FRouter-XS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2FRouter-XS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2FRouter-XS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnmfarrell","download_url":"https://codeload.github.com/dnmfarrell/Router-XS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242157180,"owners_count":20081036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T02:24:20.081Z","updated_at":"2026-04-20T01:35:09.768Z","avatar_url":"https://github.com/dnmfarrell.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nRouter::XS - Fast URI path to value lookup\n\n# SYNOPSIS\n\n    use Router::XS ':all';\n\n    my $user_home_page = sub  { ... };\n\n    add_route('/user/*', $user_home_page);\n    my ($sub, @captures) = check_route('/user/foobar');\n\n    # or use HTTP method verbs to add routes\n    get '/user/*' =\u003e sub { ... };\n\n    my ($sub, @captures) = check_route('GET/user/foobar');\n\n# FUNCTIONS\n\n## add\\_route ($path, $sub)\n\nAdds a new route associated with a subroutine to the router. Will `die` if a\nmatching route has already been added. Accepts asterisks (`*`) as wildcards\nfor captures. `$path` may be prepended with an HTTP method:\n\n    add_route('POST/some/path', $sub);\n\n## check\\_route ($path)\n\nChecks a URI path against the added routes and returns `undef` if no match is\nfound, otherwise returning the associated subroutine reference and any captures\nfrom wildcards:\n\n    my ($sub, @captures) = check_route('POST/some/path');\n\n## get/post/put/patch/del/head/conn/options/any\n\nSugar for `add_route`: adds a route using `$path` for the associated HTTP\nmethod:\n\n    put '/product/*' =\u003e sub { ... };\n\nThe `any` function accepts any HTTP method. When an incoming request is\nreceived, `check_route` must still be called.\n\nSee the test file included in this distribution for further examples.\n\n# THREAD SAFETY\n\nRouter::XS is not thread safe: however if you add all routes at the startup of\nan application under a single thread, and do not call `add_route` thereafter,\nit should be thread safe.\n\n# BENCHMARKS\n\nOn my machine Router::XS performs well against other fast Routers. The test\nconditions add 200 routes, and then check how fast the router can match the\npath '/interstitial/track':\n\n                       Rate  Router::Boom  Router::R3  Router::XS\n    Router::Boom   344536/s            --        -85%        -93%\n    Router::R3    2235343/s          549%          --        -54%\n    Router::XS    4860641/s         1311%        117%          --\n\n## DEPENDENCIES\n\nThis module uses [uthash](http://troydhanson.github.com/uthash/) to build a\nn-ary tree of paths. `uthash` is a single C header file, included in this\ndistribution. uthash is copyright (c) 2003-2017, Troy D. Hanson.\n\n# INSTALLATION\n\n    perl Makefile.PL\n    make\n    make test\n    make install\n\n# AUTHOR\n\n© 2017 David Farrell\n\n# LICENSE\n\nThe (two-clause) FreeBSD License\n\n# ACKNOWLEDGEMENTS\n\nThanks to [ZipRecruiter](https://www.ziprecruiter.com) for letting their employees contribute to Open Source.\n\n# SEE ALSO\n\nThere are many routers on [CPAN](https://metacpan.org/search?size=20\u0026q=Router) including:\n\n- [HTTP::Router](https://metacpan.org/pod/HTTP::Router)\n- [Path::Router](https://metacpan.org/pod/Path::Router)\n- [Router::Boom](https://metacpan.org/pod/Router::Boom)\n- [Router::R3](https://metacpan.org/pod/Router::R3)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnmfarrell%2Frouter-xs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnmfarrell%2Frouter-xs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnmfarrell%2Frouter-xs/lists"}