graphiti-api / graphiti-rails

MIT License
54 stars 28 forks source link

`context_for_endpoint` doesn't work if you have routing constraints #34

Open wagenet opened 5 years ago

wagenet commented 5 years ago

recognize_path doesn't allow for much configuration of the request which can be problematic if you have constraints in your router.

https://github.com/graphiti-api/graphiti-rails/blob/master/lib/graphiti/rails/railtie.rb#L134

wagenet commented 5 years ago

In my scenario the constraint was on the host, so I fixed it with:

original = Graphiti.config.context_for_endpoint
Graphiti.config.context_for_endpoint = lambda do |path, action|
  original.call(DEFAULT_HOST + path.to_s, action)
end