-
Notifications
You must be signed in to change notification settings - Fork 460
Description
We're utilizing tapir endpoint definitions for both server and client (with scala js).
We've recently encountered a problem with routing, described at #141
To be honest it was (an unpleasant) surprise that if there's a path decoding mismatch, interpreter doesn't try other endpoints. IMHO it makes no sense for this not to be the default
The documented workaround suggestion is to adjust definition with special attribute to endpoint Atom input, using a onDecodeFailureNextEndpoint extension
import sttp.tapir.server.interceptor.decodefailure.DefaultDecodeFailureHandler.OnDecodeFailure.*
// If your codec for UserId fails, allow checking other endpoints for possible matches, like /customer/some_special_case
endpoint.in("customer" / path[UserId]("user_id").onDecodeFailureNextEndpoint)But the problem is that this involves a server-side library.
Theoretically, I could traverse inputs of every endpoint before mounting them, and apply extension to PathCaptures, but I can't find how do it easily. Constructing a Pair back requires ParamConcat implicits which are not carried.
I think I will end up with platform-specific helper code around path[Input] that will use server library attributes at JVM and do nothing on JS, but that doesn't look pretty.
As the everyday user of the tapir, I wish I can set this in my shared endpoint-definition code.
But make it a default behaviour is better! 😃