1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! A service for route management.
use HashMap;
/// Returns the uri for the given route name.
/// # Examples
/// ```yaml
/// ## routes.yaml
///
/// routes:
/// - hello_world:
/// path: /hello-world
/// controller: hello_world
/// - user:
/// path: /user/{name}/{surname}
/// controller: user_controller/index
/// ```
/// ```
/// use kalgan::service::url;
/// # use std::collections::HashMap;
///
/// # kalgan::mock_settings("tests/mock/settings.yaml");
/// # kalgan::mock_routes();
/// let hello_world_uri: String = url::generate("hello_world", HashMap::new());
/// assert_eq!(hello_world_uri, "/hello-world".to_string());
///
/// let mut parameters = HashMap::new();
/// parameters.insert("name", "john".to_string());
/// parameters.insert("surname", "doe".to_string());
/// let user_uri: String = url::generate("user", parameters);
/// assert_eq!(user_uri, "/user/john/doe".to_string());
/// ```