feat(axum): build forms from checked handles
Add InteractionForm::for_handle so tests and public integration code can construct dispatched forms from generated Handle<T> values instead of raw numeric handle ids. req: ceremony/004 req: public_api/001
This commit is contained in:
@@ -159,6 +159,10 @@ impl InteractionForm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn for_handle<I>(handle: Handle<I>, fields: impl IntoIterator<Item = (String, String)>) -> Self {
|
||||||
|
Self::new(handle.id().id, fields)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse_urlencoded(body: &[u8]) -> Result<Self, InteractionFormRejection> {
|
pub fn parse_urlencoded(body: &[u8]) -> Result<Self, InteractionFormRejection> {
|
||||||
Self::from_parts(parse_urlencoded_pairs(body)?, Vec::new())
|
Self::from_parts(parse_urlencoded_pairs(body)?, Vec::new())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ fn handler_registry_dispatches_by_checked_handle() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let response = registry
|
let response = registry
|
||||||
.dispatch(InteractionForm::new(create.id().id, [("title".into(), "Hello".into())]))
|
.dispatch(InteractionForm::for_handle(create, [("title".into(), "Hello".into())]))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(response.batch.fingerprint, BuildFingerprint(123));
|
assert_eq!(response.batch.fingerprint, BuildFingerprint(123));
|
||||||
|
|||||||
Reference in New Issue
Block a user