Skip to content

Commit

Permalink
add note regarding classical "redirect after post" situations (#2434)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomTriple authored Sep 24, 2023
1 parent 798c17f commit 8559750
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions zio-http/src/main/scala/zio/http/Response.scala
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,19 @@ object Response {
def ok: Response = status(Status.Ok)

/**
* Creates an empty response with status 301 or 302 depending on if it's
* Creates an empty response with status 307 or 308 depending on if it's
* permanent or not.
*
* Note: if you intend to always redirect a browser with a HTTP GET to the
* given location you very likely should use `Response#seeOther` instead.
*/
def redirect(location: URL, isPermanent: Boolean = false): Response = {
val status = if (isPermanent) Status.PermanentRedirect else Status.TemporaryRedirect
Response(status = status, headers = Headers(Header.Location(location)))
}

/**
* Creates an empty response with status 303
* Creates an empty response with status 303.
*/
def seeOther(location: URL): Response =
Response(status = Status.SeeOther, headers = Headers(Header.Location(location)))
Expand Down

0 comments on commit 8559750

Please sign in to comment.