Closed nilgradisnik closed 5 years ago
@nilgradisnik I think if you put validation onto the header you can just put the logic in your handler, if for example the header has a key of X-Accept-Version: 2
then you just put logic in your handler to call a different method. would that solve your use case?
Closing due to inactivity. Please reopen with a reproducible example if the issue persists.
How would one go about building an API where the version is not part of an URL?
It seems like a good way to achieve this would be by introducing
condition
to .route() options which can simply be a middeware function that returns a boolean. If the true it would continue to validate and execute handlers, if not it would simply skip to the next route(if any) with the same path and method.This would give us an ability to inspect headers and execute the right validation and handlers based on the API version.
Thoughts?