Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract query params util function #6

Open
ruslanti opened this issue Oct 19, 2023 · 0 comments
Open

extract query params util function #6

ruslanti opened this issue Oct 19, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@ruslanti
Copy link
Collaborator

ruslanti commented Oct 19, 2023

common function
let query_pairs = |q: &str| { q.split('&') .filter_map(|q| { let mut i = q.splitn(2, '='); let k = i.next()?; let v = i.next()?; Some((k, v)) }) .map(|(k, v)| (k.to_owned(), v.to_owned())) .collect::<HashMap<String, String>>() }; let hash_query: HashMap<String, String> = req.uri().query().map_or(HashMap::new(), query_pairs);
is good to have as util function is sdk

@ruslanti ruslanti self-assigned this Oct 19, 2023
@ruslanti ruslanti added the enhancement New feature or request label Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant