feat(axum): parse typed interaction values

Add InteractionForm::parse for common typed field extraction and use it in example interaction handlers to avoid repeated string parsing plumbing.

req: form/004

req: dx/003

req: examples/003
This commit is contained in:
slhx agent
2026-06-02 00:31:32 +02:00
parent a462e7f097
commit 1e53a6f7df
4 changed files with 33 additions and 11 deletions
+11
View File
@@ -117,6 +117,17 @@ fn interaction_form_parses_handle_and_fields() {
assert_eq!(form.values("tag").collect::<Vec<_>>(), ["a", "b/c"]);
}
#[test]
fn interaction_form_parses_typed_values() {
// req: form/004 req: dx/003
let form = InteractionForm::parse_urlencoded(b"__h=42&count=7&bad=nope")
.expect("form should parse");
assert_eq!(form.parse::<u32>("count"), Some(7));
assert_eq!(form.parse::<u32>("bad"), None);
assert_eq!(form.parse::<u32>("missing"), None);
}
#[test]
fn interaction_form_requires_numeric_handle() {
assert_eq!(