From 93d8229bacb9c7f4079fbe5cdf86bd10d2acde1d Mon Sep 17 00:00:00 2001 From: Naftoli Gugenheim <98384+nafg@users.noreply.github.com> Date: Fri, 10 Nov 2023 02:37:53 -0500 Subject: [PATCH] RoutePattern.apply(Method, Path) (#2503) --- .../src/main/scala/zio/http/RoutePattern.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/zio-http/src/main/scala/zio/http/RoutePattern.scala b/zio-http/src/main/scala/zio/http/RoutePattern.scala index 2dc33c00f9..932605e0bf 100644 --- a/zio-http/src/main/scala/zio/http/RoutePattern.scala +++ b/zio-http/src/main/scala/zio/http/RoutePattern.scala @@ -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)) }