Endpoint

case
class Endpoint[A, I, E, O, -R](securityInput: EndpointInput[A], input: EndpointInput[I], errorOutput: EndpointOutput[E], output: EndpointOutput[O], info: EndpointInfo) extends EndpointSecurityInputsOps[A, I, E, O, R] with EndpointInputsOps[A, I, E, O, R] with EndpointErrorOutputsOps[A, I, E, O, R] with EndpointErrorOutputVariantsOps[A, I, E, O, R] with EndpointOutputsOps[A, I, E, O, R] with EndpointInfoOps[R] with EndpointMetaOps with EndpointServerLogicOps[A, I, E, O, R]

A description of an endpoint with the given inputs & outputs. The inputs are divided into two parts: security (A) and regular inputs (I). There are also two kinds of outputs: error outputs (E) and regular outputs (O).

In case there are no security inputs, the PublicEndpoint alias can be used, which omits the A parameter type.

An endpoint can be interpreted as a server, client or documentation. The endpoint requires that server/client interpreters meet the capabilities specified by R (if any).

When interpreting an endpoint as a server, the inputs are decoded and the security logic is run first, before decoding the body in the regular inputs. This allows short-circuiting further processing in case security checks fail. Server logic can be provided using EndpointServerLogicOps.serverSecurityLogic variants for secure endpoints, and EndpointServerLogicOps.serverLogic variants for public endpoints.

A concise description of an endpoint can be generated using the EndpointMetaOps.show method.

Type Params
A

Security input parameter types.

E

Error output parameter types.

I

Input parameter types.

O

Output parameter types.

R

The capabilities that are required by this endpoint's inputs/outputs. This might be Any (no requirements), sttp.capabilities.Effect (the interpreter must support the given effect type), sttp.capabilities.Streams (the ability to send and receive streaming bodies) or sttp.capabilities.WebSockets (the ability to handle websocket requests).

trait Serializable
trait Product
trait Equals
trait EndpointServerLogicOps[A, I, E, O, R]
trait EndpointOutputsOps[A, I, E, O, R]
trait EndpointOutputsMacros[A, I, E, O, R]
trait EndpointErrorOutputVariantsOps[A, I, E, O, R]
trait EndpointErrorOutputsOps[A, I, E, O, R]
trait EndpointErrorOutputsMacros[A, I, E, O, R]
trait EndpointInputsOps[A, I, E, O, R]
trait EndpointInputsMacros[A, I, E, O, R]
trait EndpointSecurityInputsOps[A, I, E, O, R]
trait EndpointSecurityInputsMacros[A, I, E, O, R]
class Object
trait Matchable
class Any
Endpoint[A, I, E, O, R]

Type members

Types

override
type EndpointType[_A, _I, _E, _O, -_R] = Endpoint[_A, _I, _E, _O, _R]
override
type ThisType[-_R] = Endpoint[A, I, E, O, _R]

Value members

Concrete methods

def httpMethod: Option[Method]

Inherited methods

def connect: Endpoint[A, I, E, O, R]
Inherited from
EndpointInputsOps
def delete: Endpoint[A, I, E, O, R]
Inherited from
EndpointInputsOps
Inherited from
EndpointInfoOps
def description(d: String): ThisType[R]
Inherited from
EndpointInfoOps
def docsExtension[D : JsonCodec](key: String, value: D): ThisType[R]
Inherited from
EndpointInfoOps
def errorOut[F, EF](o: EndpointOutput[F])(implicit ts: Aux[E, F, EF]): Endpoint[A, I, EF, O, R]
def errorOutEither[E2](o: EndpointOutput[E2]): Endpoint[A, I, Either[E, E2], O, R]

Adds a new error variant, where the current error output is represented as a Left, and the given one as a Right.

Adds a new error variant, where the current error output is represented as a Left, and the given one as a Right.

Inherited from
EndpointErrorOutputVariantsOps
def errorOutVariant[E2 >: E](o: OneOfVariant[_ <: E2]): Endpoint[A, I, E2, O, R]

Adds a new error output variant. The new variant will be checked first during encoding/decoding, before the endpoint's current output.

Adds a new error output variant. The new variant will be checked first during encoding/decoding, before the endpoint's current output.

More specifically, the current error output is replaced with a Tapir.oneOf output, where:

  • the first output variant is the given o
  • the second output variant is the current errorOutput, wrapped with Tapir.oneOfDefaultVariant
Type Params
E2

A common supertype of the new variant and the current output E.

Value Params
o

The variant to add. Can be created given an output with one of the Tapir.oneOfVariant methods.

Inherited from
EndpointErrorOutputVariantsOps
def errorOutVariantMap[E2](o: OneOfVariant[_ <: E2])(f: E => E2)(g: E2 => E): Endpoint[A, I, E2, O, R]

Adds a new error variant, where the current error output is mapped to conform to the common supertype E2 using the f and g functions.

Adds a new error variant, where the current error output is mapped to conform to the common supertype E2 using the f and g functions.

Inherited from
EndpointErrorOutputVariantsOps
def errorOutVariants[E2 >: E](first: OneOfVariant[_ <: E2], other: OneOfVariant[_ <: E2]*): Endpoint[A, I, E2, O, R]

Adds new error output variants. The new variants will be checked first during encoding/decoding, before the endpoint's current output.

Adds new error output variants. The new variants will be checked first during encoding/decoding, before the endpoint's current output.

More specifically, the current error output is replaced with a Tapir.oneOf output, where:

  • the initial output variants are the given first and other
  • the last output variant is the current errorOutput, wrapped with Tapir.oneOfDefaultVariant
Type Params
E2

A common supertype of the new variant and the current output E.

Value Params
first

The first variant to add. Can be created given an output with one of the Tapir.oneOfVariant methods.

other

Additional variants to add.

Inherited from
EndpointErrorOutputVariantsOps
def errorOutVariantsMap[E2](first: OneOfVariant[_ <: E2], other: OneOfVariant[_ <: E2]*)(f: E => E2)(g: E2 => E): Endpoint[A, I, E2, O, R]

Adds new error variants, where the current error output is mapped to conform to the common supertype E2 using the f and g functions.

Adds new error variants, where the current error output is mapped to conform to the common supertype E2 using the f and g functions.

Inherited from
EndpointErrorOutputVariantsOps
def get: Endpoint[A, I, E, O, R]
Inherited from
EndpointInputsOps
def head: Endpoint[A, I, E, O, R]
Inherited from
EndpointInputsOps
def in[BS, J, IJ, R2](i: StreamBodyIO[BS, J, R2])(implicit concat: Aux[I, J, IJ]): Endpoint[A, IJ, E, O, R & R2]
Inherited from
EndpointInputsOps
def in[J, IJ](i: EndpointInput[J])(implicit concat: Aux[I, J, IJ]): Endpoint[A, IJ, E, O, R]
Inherited from
EndpointInputsOps
Inherited from
EndpointInfoOps
def mapErrorOut[EE](f: E => EE)(g: EE => E): Endpoint[A, I, EE, O, R]
def mapErrorOut[EE](m: Mapping[E, EE]): Endpoint[A, I, EE, O, R]
def mapErrorOutDecode[EE](f: E => DecodeResult[EE])(g: EE => E): Endpoint[A, I, EE, O, R]
inline
def mapErrorOutTo[CASE_CLASS <: Product](using mc: ProductOf[CASE_CLASS]): Endpoint[A, I, CASE_CLASS, O, R]
def mapIn[II](f: I => II)(g: II => I): Endpoint[A, II, E, O, R]
Inherited from
EndpointInputsOps
def mapIn[II](m: Mapping[I, II]): Endpoint[A, II, E, O, R]
Inherited from
EndpointInputsOps
def mapInDecode[II](f: I => DecodeResult[II])(g: II => I): Endpoint[A, II, E, O, R]
Inherited from
EndpointInputsOps
inline
def mapInTo[CASE_CLASS <: Product](using mc: ProductOf[CASE_CLASS]): Endpoint[A, CASE_CLASS, E, O, R]
Inherited from
EndpointInputsMacros
def mapOut[OO](f: O => OO)(g: OO => O): Endpoint[A, I, E, OO, R]
Inherited from
EndpointOutputsOps
def mapOut[OO](m: Mapping[O, OO]): Endpoint[A, I, E, OO, R]
Inherited from
EndpointOutputsOps
def mapOutDecode[OO](f: O => DecodeResult[OO])(g: OO => O): Endpoint[A, I, E, OO, R]
Inherited from
EndpointOutputsOps
inline
def mapOutTo[CASE_CLASS <: Product](using mc: ProductOf[CASE_CLASS]): Endpoint[A, I, E, CASE_CLASS, R]
Inherited from
EndpointOutputsMacros
def mapSecurityIn[AA](f: A => AA)(g: AA => A): Endpoint[AA, I, E, O, R]
def mapSecurityIn[AA](m: Mapping[A, AA]): Endpoint[AA, I, E, O, R]
def mapSecurityInDecode[AA](f: A => DecodeResult[AA])(g: AA => A): Endpoint[AA, I, E, O, R]
inline
def mapSecurityInTo[CASE_CLASS <: Product](using mc: ProductOf[CASE_CLASS]): Endpoint[CASE_CLASS, I, E, O, R]
def method(m: Method): Endpoint[A, I, E, O, R]
Inherited from
EndpointInputsOps
def name(n: String): ThisType[R]
Inherited from
EndpointInfoOps
def options: Endpoint[A, I, E, O, R]
Inherited from
EndpointInputsOps
def out[PIPE_REQ_RESP, P, OP, R2](i: WebSocketBodyOutput[PIPE_REQ_RESP, _, _, P, R2])(implicit ts: Aux[O, P, OP]): Endpoint[A, I, E, OP, R & R2 & WebSockets]
Inherited from
EndpointOutputsOps
def out[BS, P, OP, R2](i: StreamBodyIO[BS, P, R2])(implicit ts: Aux[O, P, OP]): Endpoint[A, I, E, OP, R & R2]
Inherited from
EndpointOutputsOps
def out[P, OP](i: EndpointOutput[P])(implicit ts: Aux[O, P, OP]): Endpoint[A, I, E, OP, R]
Inherited from
EndpointOutputsOps
def patch: Endpoint[A, I, E, O, R]
Inherited from
EndpointInputsOps
def post: Endpoint[A, I, E, O, R]
Inherited from
EndpointInputsOps
def prependErrorOut[F, FE](o: EndpointOutput[F])(implicit ts: Aux[F, E, FE]): Endpoint[A, I, FE, O, R]
def prependIn[BS, J, JI, R2](i: StreamBodyIO[BS, J, R2])(implicit concat: Aux[J, I, JI]): Endpoint[A, JI, E, O, R & R2]
Inherited from
EndpointInputsOps
def prependIn[J, JI](i: EndpointInput[J])(implicit concat: Aux[J, I, JI]): Endpoint[A, JI, E, O, R]
Inherited from
EndpointInputsOps
def prependOut[PIPE_REQ_RESP, P, PO, R2](i: WebSocketBodyOutput[PIPE_REQ_RESP, _, _, P, R2])(implicit ts: Aux[P, O, PO]): Endpoint[A, I, E, PO, R & R2 & WebSockets]
Inherited from
EndpointOutputsOps
def prependOut[BS, P, PO, R2](i: StreamBodyIO[BS, P, R2])(implicit ts: Aux[P, O, PO]): Endpoint[A, I, E, PO, R]
Inherited from
EndpointOutputsOps
def prependOut[P, PO](i: EndpointOutput[P])(implicit ts: Aux[P, O, PO]): Endpoint[A, I, E, PO, R]
Inherited from
EndpointOutputsOps
def prependSecurityIn[B, BA](i: EndpointInput[B])(implicit concat: Aux[B, A, BA]): Endpoint[BA, I, E, O, R]
def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product
def put: Endpoint[A, I, E, O, R]
Inherited from
EndpointInputsOps
def renderPathTemplate(renderPathParam: RenderPathParam, renderQueryParam: Option[RenderQueryParam], includeAuth: Boolean): String

Renders endpoint path, by default all parametrised path and query components are replaced by {param_name} or {paramN}, e.g. for

Renders endpoint path, by default all parametrised path and query components are replaced by {param_name} or {paramN}, e.g. for

endpoint.in("p1" / path[String] / query[String]("par2"))

returns /p1/{param1}?par2={par2}

Value Params
includeAuth

Should authentication inputs be included in the result.

Inherited from
EndpointMetaOps
def securityIn[B, AB](i: EndpointInput[B])(implicit concat: Aux[A, B, AB]): Endpoint[AB, I, E, O, R]
def serverLogic[F[_]](f: I => F[Either[E, O]])(implicit aIsUnit: A =:= Unit): Full[Unit, Unit, I, E, O, R, F]

Combine this public endpoint description with a function, which implements the server-side logic. The logic returns a result, which is either an error or a successful output, wrapped in an effect type F. For secure endpoints, use serverSecurityLogic.

Combine this public endpoint description with a function, which implements the server-side logic. The logic returns a result, which is either an error or a successful output, wrapped in an effect type F. For secure endpoints, use serverSecurityLogic.

A server endpoint can be passed to a server interpreter. Each server interpreter supports effects of a specific type(s).

Both the endpoint and logic function are considered complete, and cannot be later extended through the returned ServerEndpoint value (except for endpoint meta-data). Secure endpoints allow providing the security logic before all the inputs and outputs are specified.

Inherited from
EndpointServerLogicOps
def serverLogicError[F[_]](f: I => F[E])(implicit aIsUnit: A =:= Unit): Full[Unit, Unit, I, E, O, R, F]

Like serverLogic, but specialised to the case when the result is always an error (Left), hence when the logic type can be simplified to I => F[E].

Like serverLogic, but specialised to the case when the result is always an error (Left), hence when the logic type can be simplified to I => F[E].

Inherited from
EndpointServerLogicOps
def serverLogicPure[F[_]](f: I => Either[E, O])(implicit aIsUnit: A =:= Unit): Full[Unit, Unit, I, E, O, R, F]

Like serverLogic, but specialised to the case when the logic function is pure, that is doesn't have any side effects.

Like serverLogic, but specialised to the case when the logic function is pure, that is doesn't have any side effects.

Inherited from
EndpointServerLogicOps
def serverLogicRecoverErrors[F[_]](f: I => F[O])(implicit eIsThrowable: E <:< Throwable, eClassTag: ClassTag[E], aIsUnit: A =:= Unit): Full[Unit, Unit, I, E, O, R, F]

Same as serverLogic, but requires E to be a throwable, and coverts failed effects of type E to endpoint errors.

Same as serverLogic, but requires E to be a throwable, and coverts failed effects of type E to endpoint errors.

Inherited from
EndpointServerLogicOps
def serverLogicSuccess[F[_]](f: I => F[O])(implicit aIsUnit: A =:= Unit): Full[Unit, Unit, I, E, O, R, F]

Like serverLogic, but specialised to the case when the result is always a success (Right), hence when the logic type can be simplified to I => F[O].

Like serverLogic, but specialised to the case when the result is always a success (Right), hence when the logic type can be simplified to I => F[O].

Inherited from
EndpointServerLogicOps
def serverSecurityLogic[U, F[_]](f: A => F[Either[E, U]]): PartialServerEndpoint[A, U, I, E, O, R, F]

Combine this endpoint description with a function, which implements the security logic of the endpoint.

Combine this endpoint description with a function, which implements the security logic of the endpoint.

Subsequently, the endpoint inputs and outputs can be extended (for error outputs, new variants can be added, but they cannot be arbitrarily extended). Then the main server logic can be provided, given a function which accepts as arguments the result of the security logic and the remaining input. The final result is then a ServerEndpoint.

A complete server endpoint can be passed to a server interpreter. Each server interpreter supports effects of a specific type(s).

An example use-case is defining an endpoint with fully-defined errors, and with security logic built-in. Such an endpoint can be then extended by multiple other endpoints, by specifying different inputs, outputs and the main logic.

Inherited from
EndpointServerLogicOps
def serverSecurityLogicError[U, F[_]](f: A => F[E]): PartialServerEndpoint[A, U, I, E, O, R, F]

Like serverSecurityLogic, but specialised to the case when the result is always an error (Left), hence when the logic type can be simplified to A => F[E].

Like serverSecurityLogic, but specialised to the case when the result is always an error (Left), hence when the logic type can be simplified to A => F[E].

Inherited from
EndpointServerLogicOps
def serverSecurityLogicPure[U, F[_]](f: A => Either[E, U]): PartialServerEndpoint[A, U, I, E, O, R, F]

Like serverSecurityLogic, but specialised to the case when the logic function is pure, that is doesn't have any side effects.

Like serverSecurityLogic, but specialised to the case when the logic function is pure, that is doesn't have any side effects.

Inherited from
EndpointServerLogicOps
def serverSecurityLogicRecoverErrors[U, F[_]](f: A => F[U])(implicit eIsThrowable: E <:< Throwable, eClassTag: ClassTag[E]): PartialServerEndpoint[A, U, I, E, O, R, F]

Same as serverSecurityLogic, but requires E to be a throwable, and coverts failed effects of type E to endpoint errors.

Same as serverSecurityLogic, but requires E to be a throwable, and coverts failed effects of type E to endpoint errors.

Inherited from
EndpointServerLogicOps
def serverSecurityLogicSuccess[U, F[_]](f: A => F[U]): PartialServerEndpoint[A, U, I, E, O, R, F]

Like serverSecurityLogic, but specialised to the case when the result is always a success (Right), hence when the logic type can be simplified to A => F[U].

Like serverSecurityLogic, but specialised to the case when the result is always a success (Right), hence when the logic type can be simplified to A => F[U].

Inherited from
EndpointServerLogicOps
def show: String

Basic information about the endpoint, excluding mapping information, with inputs sorted (first the method, then path, etc.)

Basic information about the endpoint, excluding mapping information, with inputs sorted (first the method, then path, etc.)

Inherited from
EndpointMetaOps
def showDetail: String

Detailed description of the endpoint, with inputs/outputs represented in the same order as originally defined, including mapping information.

Detailed description of the endpoint, with inputs/outputs represented in the same order as originally defined, including mapping information.

Inherited from
EndpointMetaOps
def showRaw: String

Equivalent to .toString, shows the whole case class structure.

Equivalent to .toString, shows the whole case class structure.

Inherited from
EndpointMetaOps
def summary(s: String): ThisType[R]
Inherited from
EndpointInfoOps
def tag(t: String): ThisType[R]
Inherited from
EndpointInfoOps
def tags(ts: List[String]): ThisType[R]
Inherited from
EndpointInfoOps
def trace: Endpoint[A, I, E, O, R]
Inherited from
EndpointInputsOps