Skip to content

Commit

Permalink
simplify constraints in router
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 8, 2019
1 parent bdd9b30 commit cb9ae87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
12 changes: 0 additions & 12 deletions app/constraints/api_constraint.rb

This file was deleted.

16 changes: 6 additions & 10 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,12 @@
# resources :events
# end

resources :events, constraints: ApiConstraint.new(version: 2, default: :false)
resources :old_events, path: "events", constraints: ApiConstraint.new(version: 1, default: :true)

# scope module: :v2, constraints: ApiConstraint.new(version: 2, default: :false) do
# resources :events
# end

# scope module: :v1, constraints: ApiConstraint.new(version: 1, default: :true) do
# resources :events
# end
constraints(-> (req) { req.env["HTTP_ACCEPT"].to_s.include?("version=2") }) do
resources :events
end
constraints(-> (req) { req.env["HTTP_ACCEPT"].to_s.exclude?("version=2") }) do
resources :old_events, path: "events"
end

resources :prefixes, constraints: { :id => /.+/ }
resources :provider_prefixes, path: 'provider-prefixes'
Expand Down

0 comments on commit cb9ae87

Please sign in to comment.