-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add axum::Form struct to prelude and its corresponding error #866
base: master
Are you sure you want to change the base?
Conversation
I like this and think it's a great addition to use with I think that having more ergonomic/easier forms makes proper CSRF and security policies super important, and I don't think it is something that is done currently (not 100% sure on that). Is there |
This looks great. I'm wondering - I don't see a re-export in prelude, but only a re-implementation of the Form construct. Is this what you meant originally? |
Sorry, you are correct. Form is already being re-exported from prelude already, but directly from axum, and not from loco. I'll fix that and push a commit. Stay tuned. Thanks @jondot |
Ok, pushed the prelude re-export @jondot. Also tested it here https://github.com/dsegovia90/loco_form_test/blob/master/src/controllers/home.rs, prelude re-export works as expected with the newly added error. Edit to add most relevant lines from the test repo: Let me know if there's anything else we need for this PR. Cheers! |
The only thing I'm wondering about is -- isn't this similar to just re-exporting |
Hey @jondot, sorry for the delay. Yes, it would be the same. Trying to follow the Thanks again! |
Goal
Use axum::Form extractor with loco, to improve egonomics for raw html form post requests, especially when using view_engine (with or without htmx).
The following (note that this does not use AJAX or JS, just raw html):
would work with:
This change would also allow the use of
?
operator whenever using theForm
'sFromRequest
in custom extractors like so:Edit:
Any and all feedback is welcomed, and please let me know if there's any helpful example I can write.