Crates.io | kalgan_router |
lib.rs | kalgan_router |
version | 0.9.1 |
source | src |
created_at | 2022-02-20 17:09:01.645897 |
updated_at | 2022-02-24 14:49:46.110062 |
description | HTTP routing tool based on routes stored in yaml files used by Kalgan Framework. |
homepage | https://kalgan.eduardocasas.com |
repository | https://github.com/eduardocasas/kalgan-router |
max_upload_size | |
id | 535842 |
size | 21,303 |
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:
## tests/routes.yaml
routes:
- home:
path: /
controller: home_controller::index
methods: get
- user:
path: /user/{id}
controller: user_controller::crud
middleware: user_middleware::test
methods: get, post, delete, put
requirements:
id: "^[0-9]+"
use kalgan_router::Router;
let router = Router::new("tests/routes.yaml");
assert_eq!(router.get_uri("home", HashMap::new()), "/".to_string())
let mut parameters = HashMap::new();
parameters.insert("id", "101".to_string());
assert_eq!(router.get_uri("user", parameters), "/user/101".to_string())
let route = router.get_route("/", "get").unwrap();
assert_eq!(route.get_name(), &"home".to_string());
assert_eq!(route.get_path(), &"/".to_string());
assert_eq!(route.get_methods(), &vec!["get".to_string()]);
assert_eq!(route.get_controller(), &"home_controller::index".to_string());
assert_eq!(route.get_middleware(), &"".to_string());
For further information please visit:
This crate is licensed under either of the following licenses: