-
-
Notifications
You must be signed in to change notification settings - Fork 475
Description
Is your feature request related to a problem? Please describe.
It's is clumsy it zio-http 3.x to encode a route that can match multiple methods. There are effectively only two options:
- Create multiple routes for each method:
Routes(
Method.GET / "foo" -> handler,
Method.PUT / "foo" -> handler
)- Use the
ANYmethod to capture all methods.
1 makes the declaration overly verbose especially if you have to enumerate many of the methods. While 2 is subject to confusing precedence rules.
Describe the solution you'd like
I would like the ability to define multiple methods for a single handler, this is useful in protocols like GraphQL where users may submit via either GET or POST. The easiest way I can think of doing this is to provide a | method that declares that a route will match either of the methods. The internals of this could probably be achieved with a bit mask, but it would be a breaking change to the current implementation, which doesn't have a "composite" concept.
Then the above could be written:
Routes(
Method.GET | Method.PUT / "foo" -> handler
)