final case class Endpoint[PathInput, Input, Err, Output, Middleware <: EndpointMiddleware](route: RoutePattern[PathInput], input: HttpCodec[RequestType, Input], output: HttpCodec[ResponseType, Output], error: HttpCodec[ResponseType, Err], doc: Doc, middleware: Middleware) extends Product with Serializable
An zio.http.endpoint.Endpoint represents an API endpoint for the HTTP
protocol. Every API has an input, which comes from a combination of the
HTTP route, query string parameters, and headers, and an output, which is the
data computed by the handler of the API.
MiddlewareInput : Example: A subset of HttpCodec[Input] that doesn't give
access to Input MiddlewareOutput: Example: A subset of Out[Output] that
doesn't give access to Output Input: Example: Int Output: Example: User
As zio.http.endpoint.Endpoint is a purely declarative encoding of an endpoint, it is possible to use this model to generate a zio.http.Route (by supplying a handler for the endpoint), to generate OpenAPI documentation, to generate a type-safe Scala client for the endpoint, and possibly, to generate client libraries in other programming languages.
- Self Type
- Endpoint[PathInput, Input, Err, Output, Middleware]
- Alphabetic
- By Inheritance
- Endpoint
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Endpoint(route: RoutePattern[PathInput], input: HttpCodec[RequestType, Input], output: HttpCodec[ResponseType, Output], error: HttpCodec[ResponseType, Err], doc: Doc, middleware: Middleware)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def ??(that: Doc): Endpoint[PathInput, Input, Err, Output, Middleware]
Returns a new API that is derived from this one, but which includes additional documentation that will be included in OpenAPI generation.
- def @@[M2 <: EndpointMiddleware](that: M2)(implicit inCombiner: Combiner[Middleware.In, @@.M2.In], outCombiner: Combiner[Middleware.Out, @@.M2.Out], errAlternator: Alternator[Middleware.Err, @@.M2.Err]): Endpoint[PathInput, Input, Err, Output, Typed[Out, Out, Out]]
Returns a new endpoint derived from this one whose middleware is composed from the existing middleware of this endpoint, and the specified middleware.
- def alternatives: Chunk[(Endpoint[PathInput, Input, Err, Output, Middleware], Condition)]
Flattens out this endpoint to a chunk of alternatives.
Flattens out this endpoint to a chunk of alternatives. Each alternative is guaranteed to not have any alternatives itself.
- def apply[A, B, C, D, E, F, G, H, I, J, K, L](a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L)(implicit ev: <:<[(A, B, C, D, E, F, G, H, I, J, K, L), Input]): Invocation[PathInput, Input, Err, Output, Middleware]
- def apply[A, B, C, D, E, F, G, H, I, J, K](a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K)(implicit ev: <:<[(A, B, C, D, E, F, G, H, I, J, K), Input]): Invocation[PathInput, Input, Err, Output, Middleware]
- def apply[A, B, C, D, E, F, G, H, I, J](a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J)(implicit ev: <:<[(A, B, C, D, E, F, G, H, I, J), Input]): Invocation[PathInput, Input, Err, Output, Middleware]
- def apply[A, B, C, D, E, F, G, H, I](a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I)(implicit ev: <:<[(A, B, C, D, E, F, G, H, I), Input]): Invocation[PathInput, Input, Err, Output, Middleware]
- def apply[A, B, C, D, E, F, G, H](a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H)(implicit ev: <:<[(A, B, C, D, E, F, G, H), Input]): Invocation[PathInput, Input, Err, Output, Middleware]
- def apply[A, B, C, D, E, F, G](a: A, b: B, c: C, d: D, e: E, f: F, g: G)(implicit ev: <:<[(A, B, C, D, E, F, G), Input]): Invocation[PathInput, Input, Err, Output, Middleware]
- def apply[A, B, C, D, E, F](a: A, b: B, c: C, d: D, e: E, f: F)(implicit ev: <:<[(A, B, C, D, E, F), Input]): Invocation[PathInput, Input, Err, Output, Middleware]
- def apply[A, B, C, D, E](a: A, b: B, c: C, d: D, e: E)(implicit ev: <:<[(A, B, C, D, E), Input]): Invocation[PathInput, Input, Err, Output, Middleware]
- def apply[A, B, C, D](a: A, b: B, c: C, d: D)(implicit ev: <:<[(A, B, C, D), Input]): Invocation[PathInput, Input, Err, Output, Middleware]
- def apply[A, B, C](a: A, b: B, c: C)(implicit ev: <:<[(A, B, C), Input]): Invocation[PathInput, Input, Err, Output, Middleware]
- def apply[A, B](a: A, b: B)(implicit ev: <:<[(A, B), Input]): Invocation[PathInput, Input, Err, Output, Middleware]
- def apply(input: Input): Invocation[PathInput, Input, Err, Output, Middleware]
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- val doc: Doc
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- val error: HttpCodec[ResponseType, Err]
- def examplesIn: Map[String, Input]
- def examplesIn(examples: (String, Input)*): Endpoint[PathInput, Input, Err, Output, Middleware]
- def examplesOut: Map[String, Output]
- def examplesOut(examples: (String, Output)*): Endpoint[PathInput, Input, Err, Output, Middleware]
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def header[A](codec: HeaderCodec[A])(implicit combiner: Combiner[Input, A]): Endpoint[PathInput, Out, Err, Output, Middleware]
Returns a new endpoint that requires the specified headers to be present.
- def implement[Env](original: Handler[Env, Err, Input, Output])(implicit trace: Trace): Route[Env, Nothing]
- def in[Input2](mediaType: MediaType, name: String, doc: Doc)(implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, Input2]): Endpoint[PathInput, Out, Err, Output, Middleware]
- def in[Input2](mediaType: MediaType, name: String)(implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, Input2]): Endpoint[PathInput, Out, Err, Output, Middleware]
- def in[Input2](mediaType: MediaType, doc: Doc)(implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, Input2]): Endpoint[PathInput, Out, Err, Output, Middleware]
- def in[Input2](mediaType: MediaType)(implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, Input2]): Endpoint[PathInput, Out, Err, Output, Middleware]
- def in[Input2](name: String, doc: Doc)(implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, Input2]): Endpoint[PathInput, Out, Err, Output, Middleware]
Returns a new endpoint derived from this one, whose request content must satisfy the specified schema and is documented.
- def in[Input2](name: String)(implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, Input2]): Endpoint[PathInput, Out, Err, Output, Middleware]
Returns a new endpoint derived from this one, whose request content must satisfy the specified schema and is documented.
- def in[Input2](doc: Doc)(implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, Input2]): Endpoint[PathInput, Out, Err, Output, Middleware]
Returns a new endpoint derived from this one, whose request content must satisfy the specified schema and is documented.
- def in[Input2](implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, Input2]): Endpoint[PathInput, Out, Err, Output, Middleware]
Returns a new endpoint derived from this one, whose request content must satisfy the specified schema.
- def inCodec[Input2](codec: HttpCodec[RequestType, Input2])(implicit combiner: Combiner[Input, Input2]): Endpoint[PathInput, Out, Err, Output, Middleware]
Returns a new endpoint derived from this one, whose request must satisfy the specified codec.
- def inStream[Input2](name: String, doc: Doc)(implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, ZStream[Any, Nothing, Input2]]): Endpoint[PathInput, Out, Err, Output, Middleware]
Returns a new endpoint derived from this one, whose input type is a stream of the specified type and is documented.
- def inStream[Input2](name: String)(implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, ZStream[Any, Nothing, Input2]]): Endpoint[PathInput, Out, Err, Output, Middleware]
Returns a new endpoint derived from this one, whose input type is a stream of the specified type.
- def inStream[Input2](doc: Doc)(implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, ZStream[Any, Nothing, Input2]]): Endpoint[PathInput, Out, Err, Output, Middleware]
Returns a new endpoint derived from this one, whose input type is a stream of the specified type and is documented.
- def inStream[Input2](implicit arg0: HttpContentCodec[Input2], combiner: Combiner[Input, ZStream[Any, Nothing, Input2]]): Endpoint[PathInput, Out, Err, Output, Middleware]
Returns a new endpoint derived from this one, whose input type is a stream of the specified typ.
- val input: HttpCodec[RequestType, Input]
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val middleware: Middleware
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- def out[Output2](status: Status, mediaType: MediaType)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, Output2]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose output type is the specified type for the specified status code.
- def out[Output2](status: Status, mediaType: MediaType, doc: Doc)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, Output2]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose output type is the specified type for the specified status code and is documented.
- def out[Output2](mediaType: MediaType, doc: Doc)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, Output2]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose output type is the specified type for the ok status code and is documented.
- def out[Output2](status: Status, doc: Doc)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, Output2]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose output type is the specified type for the specified status code and is documented.
- def out[Output2](status: Status)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, Output2]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose output type is the specified type for the specified status code.
- def out[Output2](mediaType: MediaType)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, Output2]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose output type is the specified type for the ok status code.
- def out[Output2](doc: Doc)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, Output2]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose output type is the specified type for the ok status code and is documented.
- def out[Output2](implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, Output2]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose output type is the specified type for the ok status code.
- def outCodec[Output2](codec: HttpCodec[ResponseType, Output2])(implicit alt: Alternator[Output, Output2]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose response must satisfy the specified codec.
- def outError[Err2](status: Status, doc: Doc)(implicit arg0: HttpContentCodec[Err2], alt: Alternator[Err, Err2]): Endpoint[PathInput, Input, Out, Output, Middleware]
Returns a new endpoint that can fail with the specified error type for the specified status code and is documented.
- def outError[Err2](status: Status)(implicit arg0: HttpContentCodec[Err2], alt: Alternator[Err, Err2]): Endpoint[PathInput, Input, Out, Output, Middleware]
Returns a new endpoint that can fail with the specified error type for the specified status code.
- def outErrors[Err2]: OutErrors[PathInput, Input, Err, Output, Middleware, Err2]
- def outStream[Output2](status: Status, mediaType: MediaType, doc: Doc)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, ZStream[Any, Nothing, Output2]]): Endpoint[PathInput, Input, Err, Out, Middleware]
- def outStream[Output2](status: Status, mediaType: MediaType)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, ZStream[Any, Nothing, Output2]]): Endpoint[PathInput, Input, Err, Out, Middleware]
- def outStream[Output2](mediaType: MediaType, doc: Doc)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, ZStream[Any, Nothing, Output2]]): Endpoint[PathInput, Input, Err, Out, Middleware]
- def outStream[Output2](mediaType: MediaType)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, ZStream[Any, Nothing, Output2]]): Endpoint[PathInput, Input, Err, Out, Middleware]
- def outStream[Output2](status: Status, doc: Doc)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, ZStream[Any, Nothing, Output2]]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose output type is a stream of the specified type for the specified status code and is documented.
- def outStream[Output2](doc: Doc)(implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, ZStream[Any, Nothing, Output2]]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose output type is a stream of the specified type for the ok status code.
- def outStream[Output2](implicit arg0: HttpContentCodec[Output2], alt: Alternator[Output, ZStream[Any, Nothing, Output2]]): Endpoint[PathInput, Input, Err, Out, Middleware]
Returns a new endpoint derived from this one, whose output type is a stream of the specified type for the ok status code.
- val output: HttpCodec[ResponseType, Output]
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def query[A](codec: QueryCodec[A])(implicit combiner: Combiner[Input, A]): Endpoint[PathInput, Out, Err, Output, Middleware]
Returns a new endpoint that requires the specified query.
- val route: RoutePattern[PathInput]
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def transformError[Err1](f: (Err) => Err1)(g: (Err1) => Err): Endpoint[PathInput, Input, Err1, Output, Middleware]
Transforms the error of this endpoint using the specified functions.
- def transformIn[Input1](f: (Input) => Input1)(g: (Input1) => Input): Endpoint[PathInput, Input1, Err, Output, Middleware]
Transforms the input of this endpoint using the specified functions.
Transforms the input of this endpoint using the specified functions. This is useful to build from different http inputs a domain specific input.
For example
case class ChangeUserName(userId: UUID, name: String) val endpoint = Endpoint(Method.POST / "user" / uuid("userId") / "changeName").in[String] .transformIn { case (userId, name) => ChangeUserName(userId, name) } { case ChangeUserName(userId, name) => (userId, name) }
- def transformOut[Output1](f: (Output) => Output1)(g: (Output1) => Output): Endpoint[PathInput, Input, Err, Output1, Middleware]
Transforms the output of this endpoint using the specified functions.
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])