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

Routing methods dsl refactored to get rid of explicit paths parameter #813

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
0.9.1 (Next)
============

* [#803](/~https://github.com/intridea/grape/pull/803), [#820](/~https://github.com/intridea/grape/pull/820): Added `all_or_none_of` parameter validator - [@loveltyoic](/~https://github.com/loveltyoic), [@natecj](/~https://github.com/natecj).
* [#803](/~https://github.com/intridea/grape/pull/803): Added `all_or_none_of` parameter validator - [@loveltyoic](/~https://github.com/loveltyoic).
* [#774](/~https://github.com/intridea/grape/pull/774): Extended `mutually_exclusive`, `exactly_one_of`, `at_least_one_of` to work inside any kind of group: `requires` or `optional`, `Hash` or `Array` - [@ShPakvel](/~https://github.com/ShPakvel).
* [#743](/~https://github.com/intridea/grape/pull/743): Added `allow_blank` parameter validator to validate non-empty strings - [@elado](/~https://github.com/elado).
* [#745](/~https://github.com/intridea/grape/pull/745): Removed `atom+xml`, `rss+xml`, and `jsonapi` content-types - [@akabraham](/~https://github.com/akabraham).
Expand All @@ -13,6 +13,7 @@
* [#809](/~https://github.com/intridea/grape/pull/809): Removed automatic `(.:format)` suffix on paths if you're using only one format (e.g., with `format :json`, `/path` will respond with JSON but `/path.xml` will be a 404) - [@ajvondrak](/~https://github.com/ajvondrak).
* [#816](/~https://github.com/intridea/grape/pull/816): Added ability to filter out missing params if params is a nested hash with `declared(params, include_missing: false)` - [@georgimitev](/~https://github.com/georgimitev).
* [#819](/~https://github.com/intridea/grape/pull/819): Allowed both `desc` and `description` in the params DSL - [@mzikherman](/~https://github.com/mzikherman).
* [#813](/~https://github.com/intridea/grape/pull/813): Routing methods dsl refactored to get rid of explicit `paths` parameter - [@AlexYankee](/~https://github.com/AlexYankee).
* Your contribution here.

0.9.0 (8/27/2014)
Expand Down
32 changes: 6 additions & 26 deletions lib/grape/dsl/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,32 +115,12 @@ def route(methods, paths = ['/'], route_options = {}, &block)
reset_validations!
end

def get(paths = ['/'], options = {}, &block)
route('GET', paths, options, &block)
end

def post(paths = ['/'], options = {}, &block)
route('POST', paths, options, &block)
end

def put(paths = ['/'], options = {}, &block)
route('PUT', paths, options, &block)
end

def head(paths = ['/'], options = {}, &block)
route('HEAD', paths, options, &block)
end

def delete(paths = ['/'], options = {}, &block)
route('DELETE', paths, options, &block)
end

def options(paths = ['/'], options = {}, &block)
route('OPTIONS', paths, options, &block)
end

def patch(paths = ['/'], options = {}, &block)
route('PATCH', paths, options, &block)
%w"get post put head delete options patch".each do |meth|
define_method meth do |*args, &block|
options = args.extract_options!
paths = args.first || ['/']
route(meth.upcase, paths, options, &block)
end
end

def namespace(space = nil, options = {}, &block)
Expand Down