Skip to content

Commit

Permalink
refactor: rename whenPath to whenPathEq
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Feb 24, 2022
1 parent da0837f commit 2635505
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object Main extends App {
.exitCode
}
private val path = "/plaintext"
private def app(response: Response) = Http.fromHExit(HExit.succeed(response)).whenPath(path)
private def app(response: Response) = Http.fromHExit(HExit.succeed(response)).whenPathEq(path)

private def server(response: Response) =
Server.app(app(response)) ++
Expand Down
8 changes: 4 additions & 4 deletions zio-http/src/main/scala/zhttp/http/Http.scala
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,12 @@ object Http {
/**
* Applies Http based on the path
*/
def whenPath(p: Path): HttpApp[R, E] = http.when((a: Request) => a.path.equals(p))
def whenPathEq(p: Path): HttpApp[R, E] = http.whenPathEq(p.toString)

/**
* Applies Http based on the path as string
*/
def whenPath(p: String): HttpApp[R, E] = http.when((a: Request) => a.unsafeEncode.uri().contentEquals(p))
def whenPathEq(p: String): HttpApp[R, E] = http.when(_.unsafeEncode.uri().contentEquals(p))

private[zhttp] def compile[R1 <: R](
zExec: HttpRuntime[R1],
Expand Down Expand Up @@ -843,11 +843,11 @@ object Http {

private case class Attempt[A](a: () => A) extends Http[Any, Nothing, Any, A]

private case object Empty extends Http[Any, Nothing, Any, Nothing]

private final case class FromHExit[R, E, B](h: HExit[R, E, B]) extends Http[R, E, Any, B]

private final case class When[R, E, A, B](f: A => Boolean, other: Http[R, E, A, B]) extends Http[R, E, A, B]

private case object Empty extends Http[Any, Nothing, Any, Nothing]

private case object Identity extends Http[Any, Nothing, Any, Nothing]
}

1 comment on commit 2635505

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance Benchmark:

Concurrency: 256
Requests/sec: 951008.38

Please sign in to comment.