Skip to content
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

Allow customizing status of redirect #401

Open
hackeryarn opened this issue Jun 9, 2024 · 0 comments
Open

Allow customizing status of redirect #401

hackeryarn opened this issue Jun 9, 2024 · 0 comments

Comments

@hackeryarn
Copy link
Contributor

Right now, redirect always issues a 302. This means that the redirect will use the same method. This becomes a problem in a common case of needing to redirect on a DELETE action.

For example, if I have:

  delete "/contacts/:contactId/" $ do
    cid <- S.pathParam "contactId"
    lift $ deleteContact cid
    redirect "/contacts"

it will redirect to DELETE /contacts which is not what I would want. I can easily fix this browser behavior by changing the status to 303, which will cause the next call to be a GET. However, there is no way to to change this status in Scotty.

We could handle this in one of two ways:

  • Have redirect respect the the status set by a previous status call.
  • Create a redirectStatus that also takes a status and URL parameter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants