You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I have a set of endpoints implemented using Finatra, and I'd like to add support for different Request/Response types depending on the API version. The issue I'm having is that the version will be passed through the header, so the actual route defined in the controller will always be the same. I know an alternative could be to version in the path, ex have v1/my/endpoint and v2/my/endpoint defined separately where I could easily have different Request/Response types defined, but the requirements I need to follow include passing the version through the header (passing it as a query param is also an option if that's easier to do in Finatra). I have been able to find a way to support returning multiple Response types depending on the version, but can't seem to get this working for the Request.
Describe the solution you'd like
One suggestion would be to support some kind of header based routing where we can define multiple routes in the controller whose paths might be the same, but expect different values for a specified header param. Ex:
There are probably multiple ways to go about this, so any solution is fine by me. Additionally if there is already a workaround to support this that I may have missed, please let me know.
Describe alternatives you've considered
I've already tried creating a base CustomRequest trait, having the two separate requests extend from that, and using that in the controller; ex:
trait CustomRequestBase
case class CustomRequestV1( ...)
case class CustomRequestV2(...)
get(route = "/my/endpoint") { req = CustomRequestBase => ...
}
but ran into some issues getting this to work.
Additional context
As mentioned above, if there is already a way I can implement my endpoints to support different Request types that I may have missed, please advise. Thank you!
The text was updated successfully, but these errors were encountered:
The endpoint initially parses the request into the Hello case class, which only cares about the v version param, and passes along the request. We can then use the DefaultMessageBodyReader to further parse the request into HelloV1 or HelloV2 depending on the version number.
Is your feature request related to a problem? Please describe.
I have a set of endpoints implemented using Finatra, and I'd like to add support for different Request/Response types depending on the API version. The issue I'm having is that the version will be passed through the header, so the actual route defined in the controller will always be the same. I know an alternative could be to version in the path, ex have
v1/my/endpoint
andv2/my/endpoint
defined separately where I could easily have different Request/Response types defined, but the requirements I need to follow include passing the version through the header (passing it as a query param is also an option if that's easier to do in Finatra). I have been able to find a way to support returning multiple Response types depending on the version, but can't seem to get this working for the Request.Describe the solution you'd like
One suggestion would be to support some kind of header based routing where we can define multiple routes in the controller whose paths might be the same, but expect different values for a specified header param. Ex:
There are probably multiple ways to go about this, so any solution is fine by me. Additionally if there is already a workaround to support this that I may have missed, please let me know.
Describe alternatives you've considered
I've already tried creating a base
CustomRequest
trait, having the two separate requests extend from that, and using that in the controller; ex:but ran into some issues getting this to work.
Additional context
As mentioned above, if there is already a way I can implement my endpoints to support different Request types that I may have missed, please advise. Thank you!
The text was updated successfully, but these errors were encountered: