multiverse
multiverse copied to clipboard
RFC: Add Plug/Phoenix-style macros for route matching in gateways
Whenever gateway is applied, it's responsibility of the package user to identify on which endpoints it should run, but it would be much nicer to be able to use route matching there, like this:
# No method means all methods
mutate_request "/plans/:id" do
end
# Only for GET requests
mutate_request :get, "/plans" do
end
mutate_response "/plans/:id" do
end
mutate_response :get, "/plans" do
end
Additional benefit is that gate would be self-documenting in a way that it's easy to see all changes per endpoint and even to generate simple changelog for them.
TODO:
- [ ] Do not forget to add new macros to
.formatter.exs
so that they won't be wrapped in brackets.
It might be better to group handlers by endpoint instead of request/response, for example,
mutate_endpoint :get, "/plans" do
:request ->
...
:response ->
...
end