Skip to content

Commit

Permalink
add methods to update the body of a request (#2571)
Browse files Browse the repository at this point in the history
  • Loading branch information
yisraelU authored Dec 27, 2023
1 parent 93df80a commit badb929
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions zio-http/src/main/scala/zio/http/Request.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ final case class Request(
def unnest(prefix: Path): Request =
copy(url = self.url.copy(path = self.url.path.unnest(prefix)))

/**
* Returns a request with a body derived from the current body.
*/
def updateBody(f: Body => Body): Request = self.copy(body = f(body))

/**
* Returns a request with a body derived from the current body in an effectful
* way.
*/
def updateBodyZIO[R, E](f: Body => ZIO[R, E, Body]): ZIO[R, E, Request] = f(body).map(withBody)

/**
* Returns a request with the specified body.
*/
def withBody(body: Body): Request = self.copy(body = body)

/**
* Returns the cookie with the given name if it exists.
*/
Expand Down

0 comments on commit badb929

Please sign in to comment.