Unclear how to deserialize a form within a request body #3113
Replies: 1 comment
-
If the request is well-formed, even if invalid from a business logic perspective then, After that, the (For completeness, I want to point out that |
Beta Was this translation helpful? Give feedback.
-
The current patterns is to use a
FormConfig
and then theForm<T>
extractor. The config has an err handler function, but that's not remotely close to what I want. If a user POSTs a form, I want to be able to read the form and render the page with errors under each form field. I can get access to these errors by writing a custom deserializer for my struct (fine, but annoying), but there's no apparent way to get this behavior one has with Python + Flask + WTForms.This means I have one place I register the page on the original GET and the POST if the data is invalid. Actix-web moves my handler somewhere extremely far away if I follow the expected pattern like:
So you'd think I can do something like this:
Except I get type errors from
take_payload
and there's not a clear way to coerce the types around. What is the incantation I need to do so that I can deserialize a form within a handler?Beta Was this translation helpful? Give feedback.
All reactions