Endpoint
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; when using a synchronous server, you can also use the more concise EndpointServerLogicOps.handle methods, which work the save as above, but have the "effect" type fixed to Identity.
A concise description of an endpoint can be generated using the EndpointMetaOps.show method.
Type parameters
- ERROR_OUTPUT
-
Error output parameter types, abbreviated as
E
. - INPUT
-
Input parameter types, abbreviated as
I
. - OUTPUT
-
Output parameter types, abbreviated as
O
. - 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). - SECURITY_INPUT
-
Security input parameter types, abbreviated as
A
.
Attributes
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait EndpointMetaOpstrait EndpointInfoOps[R]class Objecttrait Matchableclass AnyShow all
- Self type
-
Members list
Type members
Types
Value members
Inherited methods
Attributes
- Inherited from:
- EndpointInfoOps
Attributes
- Inherited from:
- EndpointInfoOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointInfoOps
Attributes
- Inherited from:
- EndpointInfoOps
Attributes
- Inherited from:
- EndpointErrorOutputsOps
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
.
Attributes
- Inherited from:
- EndpointErrorOutputVariantsOps
Replaces the current error output with a Tapir.oneOf output, where:
Replaces the current error output with a Tapir.oneOf output, where:
- the first output variant is the current output:
oneOfVariant(errorOutput)
- the second output variant is the given
o
The variant for the current endpoint output will be created using Tapir.oneOfVariant. Hence, the current output will be used if the run-time class of the output matches E
. If the erasure of the E
type is different from E
, 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 considered after the current variant.
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.
Type parameters
- E2
-
A common supertype of the new variant and the current output
E
.
Value parameters
- o
-
The variant to add. Can be created given an output with one of the Tapir.oneOfVariant methods.
Attributes
- Inherited from:
- EndpointErrorOutputVariantsOps
Replaces the current error output with a Tapir.oneOf output, where:
Replaces the current error output with a Tapir.oneOf output, where:
- the first output variant is the given
o
- the second, default output variant is the current output:
oneOfDefaultVariant(errorOutput)
Useful for adding specific error variants, while the more general ones are already covered by the existing error output.
During encoding/decoding, the new o
variant will be considered before the current variant.
Adding error output variants is useful when extending the error outputs in a PartialServerEndpoint, created using EndpointServerLogicOps.serverSecurityLogic.
Type parameters
- E2
-
A common supertype of the new variant and the current output
E
.
Value parameters
- o
-
The variant to add. Can be created given an output with one of the Tapir.oneOfVariant methods.
Attributes
- Inherited from:
- EndpointErrorOutputVariantsOps
Same as errorOutVariant, but allows appending multiple variants in one go.
Same as errorOutVariant, but allows appending multiple variants in one go.
Attributes
- Inherited from:
- EndpointErrorOutputVariantsOps
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.
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.
Type parameters
- E2
-
A common supertype of the new variant and the current output
E
.
Attributes
- Inherited from:
- EndpointErrorOutputVariantsOps
Same as errorOutVariantPrepend, but allows appending multiple variants in one go.
Same as errorOutVariantPrepend, but allows appending multiple variants in one go.
Attributes
- Inherited from:
- EndpointErrorOutputVariantsOps
Attributes
- Inherited from:
- EndpointInputsOps
Direct-style variant of serverLogic, using the Identity "effect".
Direct-style variant of serverLogic, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverLogicError, using the Identity "effect".
Direct-style variant of serverLogicError, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverLogicOption, using the Identity "effect".
Direct-style variant of serverLogicOption, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverLogicRecoverErrors, using the Identity "effect".
Direct-style variant of serverLogicRecoverErrors, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverSecurityLogic, using the Identity "effect".
Direct-style variant of serverSecurityLogic, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverSecurityLogicError, using the Identity "effect".
Direct-style variant of serverSecurityLogicError, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverSecurityLogicOption, using the Identity "effect".
Direct-style variant of serverSecurityLogicOption, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverSecurityLogicOptionWithOutput, using the Identity "effect".
Direct-style variant of serverSecurityLogicOptionWithOutput, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverSecurityLogicRecoverErrors, using the Identity "effect".
Direct-style variant of serverSecurityLogicRecoverErrors, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverSecurityLogicRecoverErrorsWithOutput, using the Identity "effect".
Direct-style variant of serverSecurityLogicRecoverErrorsWithOutput, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverSecurityLogicSuccess, using the Identity "effect".
Direct-style variant of serverSecurityLogicSuccess, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverSecurityLogicSuccessWithOutput, using the Identity "effect".
Direct-style variant of serverSecurityLogicSuccessWithOutput, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverSecurityLogicWithOutput, using the Identity "effect".
Direct-style variant of serverSecurityLogicWithOutput, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Direct-style variant of serverLogicSuccess, using the Identity "effect".
Direct-style variant of serverLogicSuccess, using the Identity "effect".
Attributes
- Inherited from:
- EndpointServerLogicOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointInfoOps
Attributes
- Inherited from:
- EndpointErrorOutputVariantsOps
Attributes
- Inherited from:
- EndpointErrorOutputsOps
Attributes
- Inherited from:
- EndpointErrorOutputsOps
Attributes
- Inherited from:
- EndpointErrorOutputsMacros
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointInputsMacros
Attributes
- Inherited from:
- EndpointOutputsOps
Attributes
- Inherited from:
- EndpointOutputsOps
Attributes
- Inherited from:
- EndpointOutputsOps
Attributes
- Inherited from:
- EndpointOutputsMacros
Attributes
- Inherited from:
- EndpointSecurityInputsOps
Attributes
- Inherited from:
- EndpointSecurityInputsOps
Attributes
- Inherited from:
- EndpointSecurityInputsOps
Attributes
- Inherited from:
- EndpointSecurityInputsMacros
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointInfoOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointOutputsOps
Attributes
- Inherited from:
- EndpointOutputsOps
Attributes
- Inherited from:
- EndpointOutputsOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointErrorOutputsOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointOutputsOps
Attributes
- Inherited from:
- EndpointOutputsOps
Attributes
- Inherited from:
- EndpointOutputsOps
Attributes
- Inherited from:
- EndpointSecurityInputsOps
Attributes
- Inherited from:
- Product
Attributes
- Inherited from:
- Product
Attributes
- Inherited from:
- EndpointInputsOps
Attributes
- Inherited from:
- EndpointSecurityInputsOps
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.
Attributes
- Inherited from:
- EndpointServerLogicOps
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]
.
Attributes
- Inherited from:
- EndpointServerLogicOps
Like serverLogic, but specialised to the case when the result is always a pure error (Left
), that is doesn't have any side effects.
Like serverLogic, but specialised to the case when the result is always a pure error (Left
), that is doesn't have any side effects.
Attributes
- Inherited from:
- EndpointServerLogicOps
Like serverLogic, but specialised to the case when the error type is Unit
(e.g. a fixed status code), and the result of the logic function is an option. A None
is then treated as an error response.
Like serverLogic, but specialised to the case when the error type is Unit
(e.g. a fixed status code), and the result of the logic function is an option. A None
is then treated as an error response.
Attributes
- Inherited from:
- EndpointServerLogicOps
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.
Attributes
- Inherited from:
- EndpointServerLogicOps
Same as serverLogic, but requires E
to be a throwable, and converts failed effects of type E
to endpoint errors.
Same as serverLogic, but requires E
to be a throwable, and converts failed effects of type E
to endpoint errors.
Attributes
- Inherited from:
- EndpointServerLogicOps
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]
.
Attributes
- Inherited from:
- EndpointServerLogicOps
Like serverLogic, but specialised to the case when the result is always a pure success (Right
), that is doesn't have any side effects.
Like serverLogic, but specialised to the case when the result is always a pure success (Right
), that is doesn't have any side effects.
Attributes
- Inherited from:
- EndpointServerLogicOps
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.
Attributes
- Inherited from:
- EndpointServerLogicOps
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]
.
Attributes
- Inherited from:
- EndpointServerLogicOps
Like serverSecurityLogic, but specialised to the case when the error type is Unit
(e.g. a fixed status code), and the result of the logic function is an option. A None
is then treated as an error response.
Like serverSecurityLogic, but specialised to the case when the error type is Unit
(e.g. a fixed status code), and the result of the logic function is an option. A None
is then treated as an error response.
Attributes
- Inherited from:
- EndpointServerLogicOps
Like serverSecurityLogicWithOutput, but specialised to the case when the error type is Unit
(e.g. a fixed status code), and the result of the logic function is an option. A None
is then treated as an error response.
Like serverSecurityLogicWithOutput, but specialised to the case when the error type is Unit
(e.g. a fixed status code), and the result of the logic function is an option. A None
is then treated as an error response.
Attributes
- Inherited from:
- EndpointServerLogicOps
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.
Attributes
- Inherited from:
- EndpointServerLogicOps
Like serverSecurityLogicWithOutput, but specialised to the case when the logic function is pure, that is doesn't have any side effects.
Like serverSecurityLogicWithOutput, but specialised to the case when the logic function is pure, that is doesn't have any side effects.
Attributes
- Inherited from:
- EndpointServerLogicOps
Same as serverSecurityLogic, but requires E
to be a throwable, and converts failed effects of type E
to endpoint errors.
Same as serverSecurityLogic, but requires E
to be a throwable, and converts failed effects of type E
to endpoint errors.
Attributes
- Inherited from:
- EndpointServerLogicOps
Same as serverSecurityLogicWithOutput, but requires E
to be a throwable, and converts failed effects of type E
to endpoint errors.
Same as serverSecurityLogicWithOutput, but requires E
to be a throwable, and converts failed effects of type E
to endpoint errors.
Attributes
- Inherited from:
- EndpointServerLogicOps
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[PRINCIPAL]
.
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[PRINCIPAL]
.
Attributes
- Inherited from:
- EndpointServerLogicOps
Like serverSecurityLogicWithOutput, but specialised to the case when the result is always a success (Right
), hence when the logic type can be simplified to A => F[(O, PRINCIPAL)]
.
Like serverSecurityLogicWithOutput, but specialised to the case when the result is always a success (Right
), hence when the logic type can be simplified to A => F[(O, PRINCIPAL)]
.
Attributes
- Inherited from:
- EndpointServerLogicOps
Like serverSecurityLogic, but allows the security function to contribute to the overall output of the endpoint. A value for the complete output O
defined so far has to be provided. The value PRINCIPAL
will be propagated as an input to the regular logic.
Like serverSecurityLogic, but allows the security function to contribute to the overall output of the endpoint. A value for the complete output O
defined so far has to be provided. The value PRINCIPAL
will be propagated as an input to the regular logic.
Attributes
- Inherited from:
- EndpointServerLogicOps
Shows endpoint path, by default all parametrised path and query components are replaced by {param_name} or {paramN}, e.g. for
Shows 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 parameters
- includeAuth
-
Should authentication inputs be included in the result.
- showNoPathAs
-
How to show the path if the endpoint does not define any path inputs.
- showPathsAs
-
How to show Tapir.paths inputs (if at all), which capture multiple paths segments
- showQueryParamsAs
-
How to show Tapir.queryParams inputs (if at all), which capture multiple query parameters
Attributes
- Inherited from:
- EndpointMetaOps
Equivalent to .toString
, shows the whole case class structure.
Equivalent to .toString
, shows the whole case class structure.
Attributes
- Inherited from:
- EndpointMetaOps
Attributes
- Inherited from:
- EndpointInfoOps
Append t
to the existing tags.
Append ts
to the existing tags.
Attributes
- Inherited from:
- EndpointInputsOps
Overwrite the existing tags with a single tag t
.
Overwrite the existing tags with ts
.
Remove all tags from this endpoint.
Inherited fields
The method defined in a fixed method input in this endpoint, if any (using e.g. EndpointInputsOps.get or EndpointInputsOps.post).
The method defined in a fixed method input in this endpoint, if any (using e.g. EndpointInputsOps.get or EndpointInputsOps.post).
Attributes
- Inherited from:
- EndpointMetaOps
Basic information about the endpoint, excluding mapping information, with inputs sorted (first the method, then path, etc.). E.g.: POST /books /add {header Authorization} {body as application/json (UTF-8)} -> {body as text/plain (UTF-8)}/-
Basic information about the endpoint, excluding mapping information, with inputs sorted (first the method, then path, etc.). E.g.: POST /books /add {header Authorization} {body as application/json (UTF-8)} -> {body as text/plain (UTF-8)}/-
Attributes
- Inherited from:
- EndpointMetaOps
Detailed description of the endpoint, with inputs/outputs represented in the same order as originally defined, including mapping information. E.g.:
Detailed description of the endpoint, with inputs/outputs represented in the same order as originally defined, including mapping information. E.g.:
Endpoint(securityin: -, in: /books POST /add {body as application/json (UTF-8)} {header Authorization}, errout: {body as text/plain (UTF-8)}, out: -)
Attributes
- Inherited from:
- EndpointMetaOps
Shortened information about the endpoint. If the endpoint is named, returns the name, e.g. [my endpoint]
. Otherwise, returns the string representation of the method (if any) and path, e.g. POST /books/add
Shortened information about the endpoint. If the endpoint is named, returns the name, e.g. [my endpoint]
. Otherwise, returns the string representation of the method (if any) and path, e.g. POST /books/add
Attributes
- Inherited from:
- EndpointMetaOps