Skip to main content

substitute_path_params

Function substitute_path_params 

Source
pub fn substitute_path_params<V: AsRef<str>>(
    path: &str,
    values: &HashMap<&str, V>,
) -> String
Expand description

Substitute {name} and :name placeholders with values[name].

Keys in values that do not appear as placeholders are ignored. A placeholder whose name is absent from values is left unchanged (callers can detect the leftover via extract_path_param_names).

ยงExamples

use apcore_toolkit::http_verb_map::substitute_path_params;
use std::collections::HashMap;

let mut values: HashMap<&str, String> = HashMap::new();
values.insert("id", "42".to_string());
assert_eq!(substitute_path_params("/users/{id}", &values), "/users/42");