Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Add Plug/Phoenix-style macros for route matching in gateways #7

Open
1 task
AndrewDryga opened this issue Feb 5, 2018 · 1 comment
Open
1 task

Comments

@AndrewDryga
Copy link
Member

AndrewDryga commented Feb 5, 2018

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.
@alco
Copy link

alco commented Feb 5, 2018

It might be better to group handlers by endpoint instead of request/response, for example,

mutate_endpoint :get, "/plans" do
  :request ->
    ...
  :response ->
    ...
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants