diff --git a/zio-http/src/main/scala/zio/http/codec/MethodCodecs.scala b/zio-http/src/main/scala/zio/http/codec/MethodCodecs.scala index 4696538137..a2186f69bf 100644 --- a/zio-http/src/main/scala/zio/http/codec/MethodCodecs.scala +++ b/zio-http/src/main/scala/zio/http/codec/MethodCodecs.scala @@ -27,8 +27,11 @@ private[codec] trait MethodCodecs { def connect: HttpCodec[Method, Unit] = method(zio.http.Method.CONNECT) def delete: HttpCodec[Method, Unit] = method(zio.http.Method.DELETE) + def head: HttpCodec[Method, Unit] = method(zio.http.Method.HEAD) def get: HttpCodec[Method, Unit] = method(zio.http.Method.GET) def options: HttpCodec[Method, Unit] = method(zio.http.Method.OPTIONS) + def patch: HttpCodec[Method, Unit] = method(zio.http.Method.PATCH) def post: HttpCodec[Method, Unit] = method(zio.http.Method.POST) def put: HttpCodec[Method, Unit] = method(zio.http.Method.PUT) + def trace: HttpCodec[Method, Unit] = method(zio.http.Method.TRACE) } diff --git a/zio-http/src/main/scala/zio/http/endpoint/Endpoint.scala b/zio-http/src/main/scala/zio/http/endpoint/Endpoint.scala index 43025bb6fd..48746d95c7 100644 --- a/zio-http/src/main/scala/zio/http/endpoint/Endpoint.scala +++ b/zio-http/src/main/scala/zio/http/endpoint/Endpoint.scala @@ -237,7 +237,7 @@ final case class Endpoint[Input, Err, Output, Middleware <: EndpointMiddleware]( object Endpoint { /** - * Constructs an endpoint for an HTTP DELETE endpoint, whose path is described + * Constructs an endpoint for an HTTP DELETE method, whose path is described * by the specified path codec. */ def delete[Input](path: PathCodec[Input]): Endpoint[Input, ZNothing, ZNothing, EndpointMiddleware.None] = { @@ -251,7 +251,7 @@ object Endpoint { } /** - * Constructs an endpoint for an HTTP GET endpoint, whose path is described by + * Constructs an endpoint for an HTTP GET method, whose path is described by * the specified path codec. */ def get[Input](path: PathCodec[Input]): Endpoint[Input, ZNothing, ZNothing, EndpointMiddleware.None] = @@ -264,8 +264,22 @@ object Endpoint { ) /** - * Constructs an endpoint for an HTTP OPTIONS endpoint, whose path is - * described by the specified path codec. + * Constructs an endpoint for an HTTP HEAD method, whose path is described by + * the specified path codec. + */ + def head[Input](path: PathCodec[Input]): Endpoint[Input, ZNothing, ZNothing, EndpointMiddleware.None] = { + Endpoint( + path ++ MethodCodec.head, + HttpCodec.unused, + HttpCodec.unused, + Doc.empty, + EndpointMiddleware.None, + ) + } + + /** + * Constructs an endpoint for an HTTP OPTIONS method, whose path is described + * by the specified path codec. */ def options[Input](path: PathCodec[Input]): Endpoint[Input, ZNothing, ZNothing, EndpointMiddleware.None] = Endpoint( @@ -277,8 +291,21 @@ object Endpoint { ) /** - * Constructs an endpoint for an HTTP POST endpoint, whose path is described - * by the specified path codec. + * Constructs an endpoint for an HTTP PATCH method, whose path is described by + * the specified path codec. + */ + def patch[Input](path: PathCodec[Input]): Endpoint[Input, ZNothing, ZNothing, EndpointMiddleware.None] = + Endpoint( + path ++ MethodCodec.patch, + HttpCodec.unused, + HttpCodec.unused, + Doc.empty, + EndpointMiddleware.None, + ) + + /** + * Constructs an endpoint for an HTTP POST method, whose path is described by + * the specified path codec. */ def post[Input](path: PathCodec[Input]): Endpoint[Input, ZNothing, ZNothing, EndpointMiddleware.None] = Endpoint( @@ -290,7 +317,7 @@ object Endpoint { ) /** - * Constructs an endpoint for an HTTP PUT endpoint, whose path is described by + * Constructs an endpoint for an HTTP PUT method, whose path is described by * the specified path codec. */ def put[Input](path: PathCodec[Input]): Endpoint[Input, ZNothing, ZNothing, EndpointMiddleware.None] = @@ -302,6 +329,19 @@ object Endpoint { EndpointMiddleware.None, ) + /** + * Constructs an endpoint for an HTTP TRACE method, whose path is described by + * the specified path codec. + */ + def trace[Input](path: PathCodec[Input]): Endpoint[Input, ZNothing, ZNothing, EndpointMiddleware.None] = + Endpoint( + path ++ MethodCodec.trace, + HttpCodec.unused, + HttpCodec.unused, + Doc.empty, + EndpointMiddleware.None, + ) + final case class OutErrors[Input, Err, Output, Middleware <: EndpointMiddleware, Err2]( self: Endpoint[Input, Err, Output, Middleware], ) extends AnyVal {