Skip to content

Commit

Permalink
RoutePattern.apply(Method, Path) (#2503)
Browse files Browse the repository at this point in the history
  • Loading branch information
nafg authored Nov 10, 2023
1 parent 985345d commit 93d8229
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions zio-http/src/main/scala/zio/http/RoutePattern.scala
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,16 @@ object RoutePattern {
*/
val any: RoutePattern[Path] = RoutePattern(Method.ANY, PathCodec.trailing)

def apply(method: Method, path: Path): RoutePattern[Unit] =
path.segments.foldLeft[RoutePattern[Unit]](fromMethod(method)) { (pathSpec, segment) =>
pathSpec./[Unit](PathCodec.Segment(SegmentCodec.literal(segment)))
}

/**
* Constructs a route pattern from a method and a path literal. To match
* against any method, use [[zio.http.Method.ANY]]. The specified string may
* contain path segments, which are separated by slashes.
*/
def apply(method: Method, value: String): RoutePattern[Unit] = {
val path = Path(value)

path.segments.foldLeft[RoutePattern[Unit]](fromMethod(method)) { (pathSpec, segment) =>
pathSpec./[Unit](PathCodec.Segment(SegmentCodec.literal(segment)))
}
}
def apply(method: Method, pathString: String): RoutePattern[Unit] =
apply(method, Path(pathString))
}

0 comments on commit 93d8229

Please sign in to comment.