Skip to content

Commit 4302df1

Browse files
changes
need to process the params. or something idk
1 parent 2728002 commit 4302df1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/hyperapp.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ pub fn source() -> Address {
164164
})
165165
}
166166

167-
/// Get query parameters from the current HTTP request path
167+
/// Get query parameters from the current HTTP request path (manually parsed)
168168
/// Returns None if not in an HTTP context or no query parameters present
169+
/// NOTE: This manually parses the path string. For pre-parsed params, use get_parsed_query_params()
169170
pub fn get_query_params() -> Option<HashMap<String, String>> {
170171
get_path().map(|path| {
171172
let mut params = HashMap::new();
@@ -183,6 +184,19 @@ pub fn get_query_params() -> Option<HashMap<String, String>> {
183184
})
184185
}
185186

187+
/// Get the pre-parsed query parameters from the current HTTP request
188+
/// Returns None if not in an HTTP context
189+
/// This accesses the query_params field that Hyperware already parsed (includes URL decoding)
190+
pub fn get_parsed_query_params() -> Option<HashMap<String, String>> {
191+
APP_HELPERS.with(|helpers| {
192+
helpers
193+
.borrow()
194+
.current_http_context
195+
.as_ref()
196+
.map(|ctx| ctx.request.query_params().clone())
197+
})
198+
}
199+
186200
pub struct Executor {
187201
tasks: Vec<Pin<Box<dyn Future<Output = ()>>>>,
188202
}

0 commit comments

Comments
 (0)