Hi,
I am used to Django framework where I could easily redirect to a previous url if required. I would simply do a return redirect(<gosomewhere>)
My typical usecase for this:
- The user is on a User Registration page with a form.
- User fills the form, click Ok and in the backgrourd the app sends the data to another URL endpoint that will register everything in the database and display a success message.
- But first it validates the data, and if something is invalid, it redirect back to the User Registration page, refill the form with the previous data, along with an error message about what the problem is.
How would I do something like that in a Rust web framework that are much more minimalist? (I am learning axum right now but I don't think actix or rocket had it either when I looked into them briefly)
Here is what I did for the moment, but it really doesn't look clean to me.
- Located at the endpoint /reg_user, I fill the form(making sure I enter some invalid data) and click Ok, it send the data to another url/handler (/register) for validation and registration in the database
- The form is validated, but since it got error, I recreate the form(using askama templating engine) and display it again with the error message. But when I do that, notice I am not back at the original /reg_user url, I am still at the /register url.
I am sure I missed something obvious somewhere
Django is nice for hobbyist like me since it does alot of "magic" like this, but the downside is that I never learned the proper way to do that in a framework that doesn't have "batteries included"