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] with Product with Serializable
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.
- A
Security input parameter types.
- I
Input parameter types.
- E
Error output 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).
- Self Type
- Endpoint[A, I, E, O, R]
- Alphabetic
- By Inheritance
- Endpoint
- Serializable
- Product
- Equals
- EndpointServerLogicOps
- EndpointMetaOps
- EndpointInfoOps
- EndpointOutputsOps
- EndpointOutputsMacros
- EndpointErrorOutputVariantsOps
- EndpointErrorOutputsOps
- EndpointErrorOutputsMacros
- EndpointInputsOps
- EndpointInputsMacros
- EndpointSecurityInputsOps
- EndpointSecurityInputsMacros
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Endpoint(securityInput: EndpointInput[A], input: EndpointInput[I], errorOutput: EndpointOutput[E], output: EndpointOutput[O], info: EndpointInfo)
Type Members
- type EndpointType[_A, _I, _E, _O, -_R] = Endpoint[_A, _I, _E, _O, _R]
- Definition Classes
- Endpoint → EndpointOutputsOps → EndpointErrorOutputVariantsOps → EndpointErrorOutputsOps → EndpointInputsOps → EndpointSecurityInputsOps
- type ThisType[-_R] = Endpoint[A, I, E, O, _R]
- Definition Classes
- Endpoint → EndpointInfoOps
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
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def connect: EndpointType[A, I, E, O, R]
- Definition Classes
- EndpointInputsOps
- def delete: EndpointType[A, I, E, O, R]
- Definition Classes
- EndpointInputsOps
- def deprecated(): ThisType[R]
- Definition Classes
- EndpointInfoOps
- def description(d: String): ThisType[R]
- Definition Classes
- EndpointInfoOps
- def docsExtension[D](key: String, value: D)(implicit arg0: JsonCodec[D]): ThisType[R]
- Definition Classes
- EndpointInfoOps
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def errorOut[F, EF](o: EndpointOutput[F])(implicit ts: typelevel.ParamConcat.Aux[E, F, EF]): EndpointType[A, I, EF, O, R]
- Definition Classes
- EndpointErrorOutputsOps
- def errorOutEither[E2](o: EndpointOutput[E2]): EndpointType[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 aRight
.Adds a new error variant, where the current error output is represented as a
Left
, and the given one as aRight
.- Definition Classes
- EndpointErrorOutputVariantsOps
- def errorOutVariant[E2 >: E](o: OneOfVariant[_ <: E2])(implicit ct: ClassTag[E], eEqualToErasure: ErasureSameAsType[E]): EndpointType[A, I, E2, O, R]
Appends a new error output variant.
Appends a new error output variant.
A variant for the current endpoint output will be created using the given Tapir.oneOfVariant. This is needed to capture the logic which allows deciding if a run-time value is applicable to a variant. If the erasure of the
E
type is different fromE
, there will be a compile-time failure, as no such run-time check is possible. In this case, use errorOutVariantsFromCurrent and create a variant using one of the other variant factory methods (e.g. Tapir.oneOfVariantValueMatcher).During encoding/decoding, the new
o
variant will be checked after the current variant.More specifically, the current error output is replaced with a Tapir.oneOf output, where:
- the first output variant is the current variant:
oneOfVariant(errorOutput)
- the second output variant is the given
o
Usage example:
sealed trait Parent case class Child1(v: String) extends Parent case class Child2(v: String) extends Parent val e: PublicEndpoint[Unit, Parent, Unit, Any] = endpoint .errorOut(stringBody.mapTo[Child1]) .errorOutVariant[Parent](oneOfVariant(stringBody.mapTo[Child2]))
Adding error output variants is useful when extending the error outputs in a PartialServerEndpoint, created using EndpointServerLogicOps.serverSecurityLogic.
- E2
A common supertype of the new variant and the current output
E
.- o
The variant to add. Can be created given an output with one of the Tapir.oneOfVariant methods.
- Definition Classes
- EndpointErrorOutputVariantsOps
- the first output variant is the current variant:
- def errorOutVariants[E2 >: E](first: OneOfVariant[_ <: E2], other: OneOfVariant[_ <: E2]*)(implicit ct: ClassTag[E], eEqualToErasure: ErasureSameAsType[E]): EndpointType[A, I, E2, O, R]
Same as errorOutVariant, but allows appending multiple variants in one go.
Same as errorOutVariant, but allows appending multiple variants in one go.
- Definition Classes
- EndpointErrorOutputVariantsOps
- def errorOutVariantsFromCurrent[E2 >: E](variants: (EndpointOutput[E]) => List[OneOfVariant[_ <: E2]]): EndpointType[A, I, E2, O, R]
Replace the error output with a Tapir.oneOf output, using the variants returned by
variants
.Replace the error output with a Tapir.oneOf output, using the variants returned by
variants
. The current output should be included in one of the returned variants.Allows creating the variant list in a custom order, placing the current variant in an arbitrary position, and using default variants if necessary.
Adding error output variants is useful when extending the error outputs in a PartialServerEndpoint, created using EndpointServerLogicOps.serverSecurityLogic.
- E2
A common supertype of the new variant and the current output
E
.
- Definition Classes
- EndpointErrorOutputVariantsOps
- val errorOutput: EndpointOutput[E]
- Definition Classes
- Endpoint → EndpointMetaOps → EndpointErrorOutputVariantsOps → EndpointErrorOutputsOps
- def get: EndpointType[A, I, E, O, R]
- Definition Classes
- EndpointInputsOps
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def head: EndpointType[A, I, E, O, R]
- Definition Classes
- EndpointInputsOps
- def in[BS, J, IJ, R2](i: StreamBodyIO[BS, J, R2])(implicit concat: typelevel.ParamConcat.Aux[I, J, IJ]): EndpointType[A, IJ, E, O, R with R2]
- Definition Classes
- EndpointInputsOps
- def in[J, IJ](i: EndpointInput[J])(implicit concat: typelevel.ParamConcat.Aux[I, J, IJ]): EndpointType[A, IJ, E, O, R]
- Definition Classes
- EndpointInputsOps
- def info(i: EndpointInfo): ThisType[R]
- Definition Classes
- EndpointInfoOps
- val info: EndpointInfo
- Definition Classes
- Endpoint → EndpointMetaOps → EndpointInfoOps
- val input: EndpointInput[I]
- Definition Classes
- Endpoint → EndpointMetaOps → EndpointInputsOps
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def mapErrorOut[EE](f: (E) => EE)(g: (EE) => E): EndpointType[A, I, EE, O, R]
- Definition Classes
- EndpointErrorOutputVariantsOps
- def mapErrorOut[EE](m: Mapping[E, EE]): EndpointType[A, I, EE, O, R]
- Definition Classes
- EndpointErrorOutputsOps
- def mapErrorOutDecode[EE](f: (E) => DecodeResult[EE])(g: (EE) => E): EndpointType[A, I, EE, O, R]
- Definition Classes
- EndpointErrorOutputsOps
- macro def mapErrorOutTo[CASE_CLASS]: EndpointType[A, I, CASE_CLASS, O, R]
- Definition Classes
- EndpointErrorOutputsMacros
- def mapIn[II](f: (I) => II)(g: (II) => I): EndpointType[A, II, E, O, R]
- Definition Classes
- EndpointInputsOps
- def mapIn[II](m: Mapping[I, II]): EndpointType[A, II, E, O, R]
- Definition Classes
- EndpointInputsOps
- def mapInDecode[II](f: (I) => DecodeResult[II])(g: (II) => I): EndpointType[A, II, E, O, R]
- Definition Classes
- EndpointInputsOps
- macro def mapInTo[CASE_CLASS]: EndpointType[A, CASE_CLASS, E, O, R]
- Definition Classes
- EndpointInputsMacros
- def mapOut[OO](f: (O) => OO)(g: (OO) => O): EndpointType[A, I, E, OO, R]
- Definition Classes
- EndpointOutputsOps
- def mapOut[OO](m: Mapping[O, OO]): EndpointType[A, I, E, OO, R]
- Definition Classes
- EndpointOutputsOps
- def mapOutDecode[OO](f: (O) => DecodeResult[OO])(g: (OO) => O): EndpointType[A, I, E, OO, R]
- Definition Classes
- EndpointOutputsOps
- macro def mapOutTo[CASE_CLASS]: EndpointType[A, I, E, CASE_CLASS, R]
- Definition Classes
- EndpointOutputsMacros
- def mapSecurityIn[AA](f: (A) => AA)(g: (AA) => A): EndpointType[AA, I, E, O, R]
- Definition Classes
- EndpointSecurityInputsOps
- def mapSecurityIn[AA](m: Mapping[A, AA]): EndpointType[AA, I, E, O, R]
- Definition Classes
- EndpointSecurityInputsOps
- def mapSecurityInDecode[AA](f: (A) => DecodeResult[AA])(g: (AA) => A): EndpointType[AA, I, E, O, R]
- Definition Classes
- EndpointSecurityInputsOps
- macro def mapSecurityInTo[CASE_CLASS]: EndpointType[CASE_CLASS, I, E, O, R]
- Definition Classes
- EndpointSecurityInputsMacros
- def method: Option[Method]
The method defined in a fixed method input in this endpoint, if any (using e.g.
The method defined in a fixed method input in this endpoint, if any (using e.g. EndpointInputsOps.get or EndpointInputsOps.post).
- Definition Classes
- EndpointMetaOps
- def method(m: Method): EndpointType[A, I, E, O, R]
- Definition Classes
- EndpointInputsOps
- def name(n: String): ThisType[R]
- Definition Classes
- EndpointInfoOps
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def options: EndpointType[A, I, E, O, R]
- Definition Classes
- EndpointInputsOps
- def out[PIPE_REQ_RESP, P, OP, R2](i: WebSocketBodyOutput[PIPE_REQ_RESP, _, _, P, R2])(implicit ts: typelevel.ParamConcat.Aux[O, P, OP]): EndpointType[A, I, E, OP, R with R2 with WebSockets]
- Definition Classes
- EndpointOutputsOps
- def out[BS, P, OP, R2](i: StreamBodyIO[BS, P, R2])(implicit ts: typelevel.ParamConcat.Aux[O, P, OP]): EndpointType[A, I, E, OP, R with R2]
- Definition Classes
- EndpointOutputsOps
- def out[P, OP](i: EndpointOutput[P])(implicit ts: typelevel.ParamConcat.Aux[O, P, OP]): EndpointType[A, I, E, OP, R]
- Definition Classes
- EndpointOutputsOps
- val output: EndpointOutput[O]
- Definition Classes
- Endpoint → EndpointMetaOps → EndpointOutputsOps
- def patch: EndpointType[A, I, E, O, R]
- Definition Classes
- EndpointInputsOps
- def post: EndpointType[A, I, E, O, R]
- Definition Classes
- EndpointInputsOps
- def prependErrorOut[F, FE](o: EndpointOutput[F])(implicit ts: typelevel.ParamConcat.Aux[F, E, FE]): EndpointType[A, I, FE, O, R]
- Definition Classes
- EndpointErrorOutputsOps
- def prependIn[BS, J, JI, R2](i: StreamBodyIO[BS, J, R2])(implicit concat: typelevel.ParamConcat.Aux[J, I, JI]): EndpointType[A, JI, E, O, R with R2]
- Definition Classes
- EndpointInputsOps
- def prependIn[J, JI](i: EndpointInput[J])(implicit concat: typelevel.ParamConcat.Aux[J, I, JI]): EndpointType[A, JI, E, O, R]
- Definition Classes
- EndpointInputsOps
- def prependOut[PIPE_REQ_RESP, P, PO, R2](i: WebSocketBodyOutput[PIPE_REQ_RESP, _, _, P, R2])(implicit ts: typelevel.ParamConcat.Aux[P, O, PO]): EndpointType[A, I, E, PO, R with R2 with WebSockets]
- Definition Classes
- EndpointOutputsOps
- def prependOut[BS, P, PO, R2](i: StreamBodyIO[BS, P, R2])(implicit ts: typelevel.ParamConcat.Aux[P, O, PO]): EndpointType[A, I, E, PO, R]
- Definition Classes
- EndpointOutputsOps
- def prependOut[P, PO](i: EndpointOutput[P])(implicit ts: typelevel.ParamConcat.Aux[P, O, PO]): EndpointType[A, I, E, PO, R]
- Definition Classes
- EndpointOutputsOps
- def prependSecurityIn[B, BA](i: EndpointInput[B])(implicit concat: typelevel.ParamConcat.Aux[B, A, BA]): EndpointType[BA, I, E, O, R]
- Definition Classes
- EndpointSecurityInputsOps
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def put: EndpointType[A, I, E, O, R]
- Definition Classes
- EndpointInputsOps
- def renderPathTemplate(renderPathParam: RenderPathParam = RenderPathTemplate.Defaults.path, renderQueryParam: Option[RenderQueryParam] = Some(RenderPathTemplate.Defaults.query), includeAuth: Boolean = true): String
Renders endpoint path, by default all parametrised path and query components are replaced by {param_name} or {paramN}, e.g.
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}
- includeAuth
Should authentication inputs be included in the result.
- Definition Classes
- EndpointMetaOps
- def securityIn[B, AB](i: EndpointInput[B])(implicit concat: typelevel.ParamConcat.Aux[A, B, AB]): EndpointType[AB, I, E, O, R]
- Definition Classes
- EndpointSecurityInputsOps
- val securityInput: EndpointInput[A]
- Definition Classes
- Endpoint → EndpointMetaOps → EndpointSecurityInputsOps
- 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.
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.
- Definition Classes
- 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 toI => 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 toI => F[E]
.- Definition Classes
- 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.
- Definition Classes
- 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 typeE
to endpoint errors.Same as serverLogic, but requires
E
to be a throwable, and coverts failed effects of typeE
to endpoint errors.- Definition Classes
- 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 toI => 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 toI => F[O]
.- Definition Classes
- 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.
- Definition Classes
- 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 toA => 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 toA => F[E]
.- Definition Classes
- 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.
- Definition Classes
- 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 typeE
to endpoint errors.Same as serverSecurityLogic, but requires
E
to be a throwable, and coverts failed effects of typeE
to endpoint errors.- Definition Classes
- 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 toA => 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 toA => F[U]
.- Definition Classes
- 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.)
- Definition Classes
- 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.
- Definition Classes
- EndpointMetaOps
- def showRaw: String
Equivalent to
.toString
, shows the whole case class structure.Equivalent to
.toString
, shows the whole case class structure.- Definition Classes
- EndpointMetaOps
- def showType: String
- Attributes
- protected
- Definition Classes
- Endpoint → EndpointMetaOps
- def summary(s: String): ThisType[R]
- Definition Classes
- EndpointInfoOps
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def tag(t: String): ThisType[R]
- Definition Classes
- EndpointInfoOps
- def tags(ts: List[String]): ThisType[R]
- Definition Classes
- EndpointInfoOps
- def trace: EndpointType[A, I, E, O, R]
- Definition Classes
- EndpointInputsOps
- 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])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
- def httpMethod: Option[Method]
- Definition Classes
- EndpointMetaOps
- Annotations
- @deprecated
- Deprecated
(Since version 0.19.0) Use method