basic query string parser function used to generate hashmaps of parameters
This hashmap is then borrowed by child functions down to the route handlers themselves if they need it
This commit is contained in:
parent
e48720d6ac
commit
83576f1126
@ -20,9 +20,22 @@ use dotenv::dotenv;
|
||||
|
||||
mod auth;
|
||||
|
||||
fn map_qs(string: Option<&str>) -> HashMap<&str, Option<&str>> {
|
||||
// if we can't find anything in the map then we no there is nothing
|
||||
unimplemented!()
|
||||
fn map_qs(query_string_raw: Option<&str>) -> HashMap<&str, &str> {
|
||||
/*
|
||||
* Parse a given query string and build a hashmap from it
|
||||
*/
|
||||
let mut map: HashMap<&str, &str> = HashMap::new();
|
||||
if let Some(qs) = query_string_raw {
|
||||
let raw_pairs: Vec<&str> = qs.split('&').collect();
|
||||
for raw_pair in raw_pairs.iter() {
|
||||
let sub_segment: Vec<&str> = raw_pair.split('=').collect();
|
||||
match sub_segment.len() {
|
||||
2 => map.insert(sub_segment[0], sub_segment[1]),
|
||||
_ => continue
|
||||
};
|
||||
}
|
||||
}
|
||||
map
|
||||
}
|
||||
|
||||
async fn route_dispatcher(resp: &Response<Body>, meth: &Method, path: &str, params: &HashMap<&str, Option<&str>>) {
|
||||
|
Loading…
Reference in New Issue
Block a user