Expand description
Leaving something for the next request from the same visitor.
A form that fails validation has to answer twice over: tell the person what
is wrong, and give them back what they typed. Neither can travel in the
response, because the answer to a failed POST is a redirect — sending the
page directly would leave the browser on a URL that re-submits the form when
reloaded, which is the double-charge problem in miniature.
So the errors and the old input are left where the next request will find them, and the browser is sent back to the form.
The trait is here rather than in rustlavel-auth on purpose. Validation
needs somewhere to leave errors and must not therefore depend on sessions;
the view layer needs to read them and must not depend on either. A session
registers itself as Arc<dyn Flash> on the request, and everything else
talks to that.
Constants§
- ERRORS_
KEY - The key a failed validation leaves its messages under.
- OLD_
INPUT_ KEY - The key it leaves the submitted input under.
- PREVIOUS_
URL_ KEY - The key the session middleware records the last page under, so a failed form knows where “back” is.
Traits§
- Flash
- Somewhere a value can be left for exactly one further request.
Functions§
- is_
local_ path - Whether a redirect target is a path on this site rather than another origin.
- old_
input_ of - The submitted fields worth keeping, as a JSON object.