Awesome!
That’s a common pattern I do as well. For example, if I’m building a form to edit a device, I may have the following:
-
GET /device/{id}/edit
(renders form)
-
POST /device/{id}
(accepts POST data from form)
- If successful, redirect to
/device/{id}/edit?success=true
- If unsuccessful, redirect to
/device/{id}/edit?error=<message>
I can then show a success or failure message to the user.
There’s a lot of reasons the POST /device/{id}
workflow could fail depending any number of validation rules (missing fields, etc). I generally like to add a message (or error code) to the error
query parameter with helpful details for the user whenever possible.