Skip to content

Commit

Permalink
align default values from HandlerAspect.redirect with Response.redire…
Browse files Browse the repository at this point in the history
…ct (#2432)
  • Loading branch information
TomTriple authored Sep 24, 2023
1 parent 53f0263 commit 07df316
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions zio-http/src/main/scala/zio/http/HandlerAspect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -596,15 +596,15 @@ private[http] trait HandlerAspects extends zio.http.internal.HeaderModifier[Hand
/**
* Creates a middleware that will redirect requests to the specified URL.
*/
def redirect(url: URL, isPermanent: Boolean): HandlerAspect[Any, Unit] =
def redirect(url: URL, isPermanent: Boolean = false): HandlerAspect[Any, Unit] =
fail(Response.redirect(url, isPermanent))

/**
* Creates middleware that will redirect requests with trailing slash to the
* same path without trailing slash.
*/
def redirectTrailingSlash(
isPermanent: Boolean,
isPermanent: Boolean = false,
): HandlerAspect[Any, Unit] =
ifRequestThenElse(request => request.url.path.hasTrailingSlash && request.url.queryParams.isEmpty)(
ifTrue = updatePath(_.dropTrailingSlash) ++ failWith(request => Response.redirect(request.url, isPermanent)),
Expand Down

0 comments on commit 07df316

Please sign in to comment.