Skip to content

Commit

Permalink
feat(patch): added updateHeaders (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrutiVerma97 authored Jan 10, 2022
1 parent bd298cf commit 52053ef
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions zio-http/src/main/scala/zhttp/http/Patch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ sealed trait Patch { self =>
case Patch.RemoveHeaders(headers) => res.removeHeaders(headers)
case Patch.SetStatus(status) => res.setStatus(status)
case Patch.Combine(self, other) => loop(self(res), other)
case Patch.UpdateHeaders(f) => res.updateHeaders(f)
}

loop(res, self)
Expand All @@ -29,11 +30,13 @@ object Patch {
final case class RemoveHeaders(headers: List[String]) extends Patch
final case class SetStatus(status: Status) extends Patch
final case class Combine(left: Patch, right: Patch) extends Patch
final case class UpdateHeaders(f: Headers => Headers) extends Patch

def empty: Patch = Empty
def addHeader(headers: Headers): Patch = AddHeaders(headers)
def addHeader(headers: Header): Patch = AddHeaders(Headers(headers))
def addHeader(name: CharSequence, value: CharSequence): Patch = AddHeaders(Headers(name, value))
def removeHeaders(headers: List[String]): Patch = RemoveHeaders(headers)
def setStatus(status: Status): Patch = SetStatus(status)
def updateHeaders(f: Headers => Headers): Patch = UpdateHeaders(f)
}

0 comments on commit 52053ef

Please sign in to comment.