sttp.tapir.server.interceptor
Members list
Packages
Type members
Classlikes
Allows customising the interceptors used by the server interpreter. Custom interceptors should usually be added using addInterceptor
. That way, the custom interceptor is called after the built-in ones (such as logging, metrics, exceptions), and before the decode failure handler. For even more flexibility, interceptors can be added to the beginning or end of the interceptor stack, using prependInterceptor
and appendInterceptor
.
Allows customising the interceptors used by the server interpreter. Custom interceptors should usually be added using addInterceptor
. That way, the custom interceptor is called after the built-in ones (such as logging, metrics, exceptions), and before the decode failure handler. For even more flexibility, interceptors can be added to the beginning or end of the interceptor stack, using prependInterceptor
and appendInterceptor
.
The first interceptor in the interceptor stack is the one which is called first on request, and processes the resulting response as the last one.
Built-in interceptors can be customised or disabled using the dedicated methods.
Once done, use options to obtain the server interpreter options objects, which can be passed to the server interpreter.
Value parameters
- additionalInterceptors
-
Additional interceptors, which will be called before (on request) / after (on response) the
decodeFailureHandler
one, e.g. performing logging, metrics, or providing alternate responses. - appendedInterceptors
-
Additional interceptors, which will be called last on request / first on response, e.g. handling decode failures, or providing alternate responses.
- decodeFailureHandler
-
The decode failure handler, from which an interceptor will be created. Determines whether to respond when an input fails to decode.
- exceptionHandler
-
Whether to respond to exceptions in the server logic, or propagate them to the server.
- metricsInterceptor
-
Whether to collect metrics.
- notAcceptableInterceptor
-
Whether to return 406 (not acceptable) if there's no body in the endpoint's outputs, which can satisfy the constraints from the
Accept
header. - prependedInterceptors
-
Additional interceptors, which will be called first on request / last on response, e.g. performing logging, metrics, or providing alternate responses.
- rejectHandler
-
How to respond when decoding fails for all interpreted endpoints.
- serverLog
-
The server log using which an interceptor will be created, if any.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Handles the result of decoding a request using an endpoint's inputs.
Handles the result of decoding a request using an endpoint's inputs.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Allows intercepting the handling of a request by an endpoint, when either the endpoint's inputs have been decoded successfully, or when decoding has failed. Ultimately, when all interceptors are run, the endpoint's server logic will be run (in case of a decode success), or None
will be returned (in case of decode failure).
Allows intercepting the handling of a request by an endpoint, when either the endpoint's inputs have been decoded successfully, or when decoding has failed. Ultimately, when all interceptors are run, the endpoint's server logic will be run (in case of a decode success), or None
will be returned (in case of decode failure).
Instead of calling the nested behavior, alternative responses can be returned using the responder
.
Attributes
- Companion
- object
- Supertypes
- Known subtypes
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
EndpointInterceptor.type
Intercepts requests, and endpoint decode events. Using interceptors it's possible to:
Intercepts requests, and endpoint decode events. Using interceptors it's possible to:
- customise the request that is passed downstream
- short-circuit further processing and provide an alternate (or no) response
- replace or modify the response that is sent back to the client
Interceptors can be called when the request is started to be processed (use RequestInterceptor in this case), or for each endpoint, with either input success of failure decoding events (see EndpointInterceptor).
To add an interceptors, modify the server options of the server interpreter.
Type parameters
- F
-
The effect type constructor.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait EndpointInterceptor[F]class NotAcceptableInterceptor[F]class DecodeFailureInterceptor[F]class ExceptionInterceptor[F]trait RequestInterceptor[F]class CORSInterceptor[F]class ServerLogInterceptor[F]class MetricsRequestInterceptor[F]class RejectInterceptor[F]Show all
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
RequestHandler.type
Allows intercepting the handling of request
, before decoding using any of the endpoints is done. The request can be modified, before invoking further behavior, passed through requestHandler
. Ultimately, when all interceptors are run, logic decoding subsequent endpoint inputs will be run.
Allows intercepting the handling of request
, before decoding using any of the endpoints is done. The request can be modified, before invoking further behavior, passed through requestHandler
. Ultimately, when all interceptors are run, logic decoding subsequent endpoint inputs will be run.
A request interceptor is called once for a request.
Instead of calling the nested behavior, alternative responses can be returned using the responder
.
Moreover, when calling requestHandler
, an EndpointInterceptor can be provided, which will be added to the list of endpoint interceptors to call. The order in which the endpoint interceptors will be called will correspond to their order in the interceptors list in the server options. An "empty" interceptor can be provided using EndpointInterceptor.noop.
Type parameters
- F
-
The effect type constructor.
Attributes
- Companion
- object
- Supertypes
- Known subtypes
-
class CORSInterceptor[F]class ServerLogInterceptor[F]class MetricsRequestInterceptor[F]class RejectInterceptor[F]
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
RequestInterceptor.type
The result of processing a request: either a response, or a list of endpoint decoding failures.
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
RequestResult.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all