diff options
| author | Fuwn <[email protected]> | 2022-03-26 05:35:50 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-03-26 05:35:50 +0000 |
| commit | ab626a81e1339623941c6f57f55bbf5018805676 (patch) | |
| tree | e4232e1c49eaa2016b11ffa233f12e6f4bb34799 /src | |
| parent | feat: expose url to route (diff) | |
| download | windmark-ab626a81e1339623941c6f57f55bbf5018805676.tar.xz windmark-ab626a81e1339623941c6f57f55bbf5018805676.zip | |
feat(utilities): queries_from_url
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 1 | ||||
| -rw-r--r-- | src/utilities.rs | 30 |
2 files changed, 31 insertions, 0 deletions
@@ -29,6 +29,7 @@ pub mod response; pub mod status; +pub mod utilities; #[cfg(feature = "logger")] #[macro_use] diff --git a/src/utilities.rs b/src/utilities.rs new file mode 100644 index 0000000..0d34dba --- /dev/null +++ b/src/utilities.rs @@ -0,0 +1,30 @@ +// This file is part of Windmark <https://github.com/gemrest/windmark>. +// Copyright (C) 2022-2022 Fuwn <[email protected]> +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +// Copyright (C) 2022-2022 Fuwn <[email protected]> +// SPDX-License-Identifier: GPL-3.0-only + +use std::collections::HashMap; + +#[must_use] +pub fn queries_from_url(url: &url::Url) -> HashMap<String, String> { + let mut queries = HashMap::new(); + + for (key, value) in url.query_pairs().collect::<Vec<(_, _)>>() { + queries.insert(key.to_string(), value.to_string()); + } + + queries +} |