Pathmaker
Generalized routing for any HTTP library. Not too fancy.
Usage
To use this library, add the following to your Cargo.toml:
= "0.1.0"
If you want to use it with a specific HTTP library, e.g. hyper, enable that
feature:
= "0.12"
= { = "0.1", = ["hyper"] }
Then, in your code, construct a router:
extern crate hyper;
extern crate pathmaker;
extern crate failure;
extern crate futures;
use ;
use make_service_fn;
use CONTENT_LENGTH;
use Router;
use Error;
use *;
Query Parameters
Support for query parameters is allowed by using {} in the path:
// ...
// ...
Then, in the handler, you can access the first element of the second argument in order to get the result:
//...
// ...
Query parameters can be filtered down by format:
{},{:string}(the default): anything that isn't a/character is matched.{:int}: a positive or negative number.{:uint}: just a number, no sign allowed.{:uuid}: a UUID, in 8-4-4-4-12 format.
More can be added if requested.
Route Evaluation
Routes are evaluated from top to bottom. The first route that matches is used.