No description, website, or topics provided.
Branch: master
Clone or download
Latest commit 6a9c4d3 Jul 27, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/HTTP/Server Update Router.pm6 Jul 27, 2017
t less verbose testing Mar 23, 2017
.gitignore less verbose testing Mar 23, 2017
.travis.yml travis + GLR fixes + s/::Threaded/::Async/g; Oct 15, 2015
META6.json Update META6.json Jul 27, 2017 fix example Jul 22, 2017

Perl6's HTTP Router for the Pros

Build Status

This here module provides a routing system for use with HTTP::Server::Async. It can accept named parameters (currently no restraints on what the parameter is), and hard typed paths. Check out below for examples and usage.


use HTTP::Server::Async;
use HTTP::Server::Router;

my HTTP::Server::Async $server .=new;

serve $server;

route '/', sub($req, $res) {
  $res.close('Hello world!');

route '/:whatever', sub($req, $res) {

route / .+ /, sub($req, $res) {
  $res.status = 404;
  $res.close('Not found.');


The example above matches a route '/' and response 'Hello world!' (complete with headers). The other route that matches is '/' and it echos <anything> back to the client. All other connections will hang until the client times them out.


Routes are called in the order they're registered. If the route's sub returns a promise, no further processing is done until that Promise is kept/broken. If the route's sub does not return a Promise then a True (or anything that indicates True) value indicates that further processing should stop. A False value means continue trying to match handlers.


Do what you will. Be careful out there amongst the English.