EndpointSpec

zio.http.api.EndpointSpec
See theEndpointSpec companion object
final case class EndpointSpec[Input, Output](input: HttpCodec[RequestType, Input], output: HttpCodec[ResponseType, Output], doc: Doc)

An zio.http.api.EndpointSpec represents an API endpoint for the HTTP protocol. Every API has an input, which comes from a combination of the HTTP path, 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.api.EndpointSpec is a purely declarative encoding of an endpoint, it is possible to use this model to generate a zio.http.App (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.

Attributes

Companion:
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Self type
EndpointSpec[Input, Output]

Members list

Concise view

Value members

Concrete methods

def ??(that: Doc): EndpointSpec[Input, Output]

Returns a new API that is derived from this one, but which includes additional documentation that will be included in OpenAPI generation.

Returns a new API that is derived from this one, but which includes additional documentation that will be included in OpenAPI generation.

Attributes

def apply(input: Input): Invocation[EndpointSpec, Input, Output]
def apply[A, B](a: A, b: B)(implicit ev: (A, B) <:< Input): Invocation[EndpointSpec, Input, Output]
def apply[A, B, C](a: A, b: B, c: C)(implicit ev: (A, B, C) <:< Input): Invocation[EndpointSpec, Input, Output]
def apply[A, B, C, D](a: A, b: B, c: C, d: D)(implicit ev: (A, B, C, D) <:< Input): Invocation[EndpointSpec, Input, Output]
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[EndpointSpec, Input, Output]
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[EndpointSpec, Input, Output]
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[EndpointSpec, Input, Output]
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[EndpointSpec, Input, Output]
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[EndpointSpec, Input, Output]
def header[A](codec: HeaderCodec[A])(implicit combiner: Combiner[Input, A]): EndpointSpec[Out, Output]
def implement[R, E](f: Input => ZIO[R, E, Output]): Endpoints[R, E, EndpointSpec]

Converts this API, which is an abstract description of an endpoint, into a service, which is a concrete implementation of the endpoint. In order to convert an API into a service, you must specify a function which handles the input, and returns the output.

Converts this API, which is an abstract description of an endpoint, into a service, which is a concrete implementation of the endpoint. In order to convert an API into a service, you must specify a function which handles the input, and returns the output.

Attributes

def in[Input2](in2: HttpCodec[RequestType, Input2])(implicit combiner: Combiner[Input, Input2]): EndpointSpec[Out, Output]

Adds a new element of input to the API, which can come from the portion of the HTTP path not yet consumed, the query string parameters, or the HTTP headers of the request.

Adds a new element of input to the API, which can come from the portion of the HTTP path not yet consumed, the query string parameters, or the HTTP headers of the request.

Attributes

def out[Output2 : Schema]: EndpointSpec[Input, Output2]

Changes the output type of the endpoint to the specified output type.

Changes the output type of the endpoint to the specified output type.

Attributes

def out[Output2](out2: HttpCodec[ResponseType, Output2])(implicit combiner: Combiner[Output, Output2]): EndpointSpec[Input, Out]
def outStream[Output2 : Schema]: EndpointSpec[Input, ZStream[Any, Throwable, Output2]]

Changes the output type of the endpoint to be a stream of the specified output type.

Changes the output type of the endpoint to be a stream of the specified output type.

Attributes

def query[A](codec: QueryCodec[A])(implicit combiner: Combiner[Input, A]): EndpointSpec[Out, Output]
def route[A](codec: RouteCodec[A])(implicit combiner: Combiner[Input, A]): EndpointSpec[Out, Output]

Convert API to a ServiceSpec.

Convert API to a ServiceSpec.

Attributes

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product