HTTP routing tool based on routes stored in yaml files used by Kalgan Framework.
This is the yaml file to be used in the following tests: ```yaml
routes:
- home:
path: /
controller: homecontroller::index
methods: get
- user:
path: /user/{id}
controller: usercontroller::crud
middleware: usermiddleware::test
methods: get, post, delete, put
requirements:
id: "^[0-9]+"
rust
use kalganrouter::Router;
let router = Router::new("tests/routes.yaml");
rust
asserteq!(router.geturi("home", HashMap::new()), "/".tostring())
rust
let mut parameters = HashMap::new();
parameters.insert("id", "101".tostring());
asserteq!(router.geturi("user", parameters), "/user/101".tostring())
rust
let route = router.getroute("/", "get").unwrap();
rust
asserteq!(route.getname(), &"home".tostring());
rust
asserteq!(route.getpath(), &"/".tostring());
rust
asserteq!(route.getmethods(), &vec!["get".tostring()]);
rust
asserteq!(route.getcontroller(), &"homecontroller::index".tostring());
rust
asserteq!(route.getmiddleware(), &"".tostring());
```
For further information please visit:
This crate is licensed under either of the following licenses: