aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-03-26 05:35:50 +0000
committerFuwn <[email protected]>2022-03-26 05:35:50 +0000
commitab626a81e1339623941c6f57f55bbf5018805676 (patch)
treee4232e1c49eaa2016b11ffa233f12e6f4bb34799 /src
parentfeat: expose url to route (diff)
downloadwindmark-ab626a81e1339623941c6f57f55bbf5018805676.tar.xz
windmark-ab626a81e1339623941c6f57f55bbf5018805676.zip
feat(utilities): queries_from_url
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs1
-rw-r--r--src/utilities.rs30
2 files changed, 31 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 0aadd66..1593b2f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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
+}