Skip to content

Commit bfb4da5

Browse files
authored
Merge pull request #1993 from ericproulx/lazy_join_allow_header
Lazy join over allow headers
2 parents 3f17a27 + 2d5a6a8 commit bfb4da5

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Your contribution here.
66

77
#### Fixes
8-
8+
* [#1993](https://github.com/ruby-grape/grape/pull/1993): Lazy join allow header - [@ericproulx](https://github.com/ericproulx).
99
* [#1987](https://github.com/ruby-grape/grape/pull/1987): Re-add exactly_one_of mutually exclusive error message - [@ZeroInputCtrl](https://github.com/ZeroInputCtrl).
1010
* [#1977](https://github.com/ruby-grape/grape/pull/1977): Skip validation for a file if it is optional and nil - [@dnesteryuk](https://github.com/dnesteryuk).
1111
* [#1976](https://github.com/ruby-grape/grape/pull/1976): Ensure classes/modules listed for autoload really exist - [@dnesteryuk](https://github.com/dnesteryuk).

lib/grape/api/instance.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def add_head_not_allowed_methods_and_options_methods
227227
allowed_methods |= [Grape::Http::Headers::HEAD] if allowed_methods.include?(Grape::Http::Headers::GET)
228228
end
229229

230-
allow_header = (self.class.namespace_inheritable(:do_not_route_options) ? allowed_methods : [Grape::Http::Headers::OPTIONS] | allowed_methods).join(', ')
230+
allow_header = (self.class.namespace_inheritable(:do_not_route_options) ? allowed_methods : [Grape::Http::Headers::OPTIONS] | allowed_methods)
231231

232232
unless self.class.namespace_inheritable(:do_not_route_options) || allowed_methods.include?(Grape::Http::Headers::OPTIONS)
233233
config[:endpoint].options[:options_route_enabled] = true

lib/grape/router.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def transaction(env)
106106
env,
107107
neighbor.allow_header,
108108
neighbor.endpoint
109-
) if neighbor && method == 'OPTIONS' && !cascade
109+
) if neighbor && method == Grape::Http::Headers::OPTIONS && !cascade
110110

111111
route = match?(input, '*')
112112
return neighbor.endpoint.call(env) if neighbor && cascade && route
@@ -160,7 +160,7 @@ def greedy_match?(input)
160160
end
161161

162162
def call_with_allow_headers(env, methods, endpoint)
163-
env[Grape::Env::GRAPE_ALLOWED_METHODS] = methods
163+
env[Grape::Env::GRAPE_ALLOWED_METHODS] = methods.join(', ')
164164
endpoint.call(env)
165165
end
166166

0 commit comments

Comments
 (0)