sttp.tapir.server.interceptor.decodefailure
DefaultDecodeFailureHandler
Companion class DefaultDecodeFailureHandler
object DefaultDecodeFailureHandler extends Serializable
- Alphabetic
- By Inheritance
- DefaultDecodeFailureHandler
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
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()
- val default: DefaultDecodeFailureHandler
The default implementation of the DecodeFailureHandler.
The default implementation of the DecodeFailureHandler.
A 400 (bad request) is returned if a query, header or body input can't be decoded (for any reason), or if decoding a path capture causes a validation error.
A 401 (unauthorized) is returned when an authentication input (created using Tapir.auth) cannot be decoded. The appropriate
WWW-Authenticateheaders are included.Otherwise (e.g. if the method, a path segment, or path capture is missing, there's a mismatch or a decode error),
Noneis returned, which is a signal to try the next endpoint.The error messages contain information about the source of the decode error, and optionally the validation error detail that caused the failure.
The default decode failure handler can be customised by providing alternate functions for deciding whether a response should be sent, creating the error message and creating the response.
Furthermore, how decode failures are handled can be adjusted globally by changing the flags passed to respond. By default, if the shape of the path for an endpoint matches the request, but decoding a path capture causes an error (e.g. a
path[Int]("amount")cannot be parsed), the next endpoint is tried. However, if there's a validation error (e.g. apath[Kind]("kind"), whereKindis an enum, and a value outside the enumeration values is provided), a 400 response is sent.Finally, behavior can be adjusted per-endpoint-input, by setting an attribute. Import the OnDecodeFailure object and use the OnDecodeFailure.RichEndpointTransput.onDecodeFailureBadRequest and OnDecodeFailure.RichEndpointTransput.onDecodeFailureNextEndpoint extension methods.
This is only used for failures that occur when decoding inputs, not for exceptions that happen when the server logic is invoked. Exceptions can be either handled by the server logic, and converted to an error output value. Uncaught exceptions can be handled using the sttp.tapir.server.interceptor.exception.ExceptionInterceptor.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def failureResponse(c: StatusCode, hs: List[Header], m: String): ValuedEndpointOutput[_]
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- val hideEndpointsWithAuth: DefaultDecodeFailureHandler
A default handler which responds with a
404 Not Found, instead of a401 Unauthorizedor400 Bad Request, in case any input fails to decode, and the endpoint contains authentication inputs (created using Tapir.auth).A default handler which responds with a
404 Not Found, instead of a401 Unauthorizedor400 Bad Request, in case any input fails to decode, and the endpoint contains authentication inputs (created using Tapir.auth). NoWWW-Authenticateheaders are sent.Hence, the information if the endpoint exists, but needs authentication is hidden from the client. However, the existence of the endpoint might still be revealed using timing attacks.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- 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 respond(ctx: DecodeFailureContext, badRequestOnPathErrorIfPathShapeMatches: Boolean, badRequestOnPathInvalidIfPathShapeMatches: Boolean): Option[(StatusCode, List[Header])]
- badRequestOnPathErrorIfPathShapeMatches
Should a status 400 be returned if the shape of the path of the request matches, but decoding some path segment fails with a DecodeResult.Error.
- badRequestOnPathInvalidIfPathShapeMatches
Should a status 400 be returned if the shape of the path of the request matches, but decoding some path segment fails with a DecodeResult.InvalidValue.
- def respondNotFoundIfHasAuth(ctx: DecodeFailureContext, response: Option[(StatusCode, List[Header])]): Option[(StatusCode, List[Header])]
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- 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])
- object FailureMessages
Default messages for DecodeResult.Failure s.
- object OnDecodeFailure
- object ValidationMessages
Default messages when the decode failure is due to a validation error.
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated