Skip to content

Commit

Permalink
Remove requirements and path from greedy route (not used)
Browse files Browse the repository at this point in the history
allow header is joined
  • Loading branch information
ericproulx committed Nov 11, 2024
1 parent db7c156 commit ccbe23c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions lib/grape/api/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,8 @@ def collect_route_config_per_pattern(all_routes)
last_route.app.options[:options_route_enabled] = true unless self.class.namespace_inheritable(:do_not_route_options) || allowed_methods.include?(Rack::OPTIONS)

@router.associate_routes(last_route.pattern, {
requirements: last_route.options[:requirements],
path: last_route.origin,
endpoint: last_route.app,
allow_header: allow_header
endpoint: last_route.app,
allow_header: allow_header.join(', ').freeze
})
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/grape/router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def transaction(env)

route = match?(input, '*')

return last_neighbor_route.endpoint.call(env) if last_neighbor_route && last_response_cascade && route
return last_neighbor_route.options[:endpoint].call(env) if last_neighbor_route && last_response_cascade && route

last_response_cascade = cascade_or_return_response.call(process_route(route, env)) if route

Expand Down Expand Up @@ -152,8 +152,8 @@ def greedy_match?(input)

def call_with_allow_headers(env, route)
prepare_env_from_route(env, route)
env[Grape::Env::GRAPE_ALLOWED_METHODS] = route.options[:allow_header].join(', ').freeze
route.endpoint.call(env)
env[Grape::Env::GRAPE_ALLOWED_METHODS] = route.options[:allow_header]
route.options[:endpoint].call(env)
end

def prepare_env_from_route(env, route)
Expand Down

0 comments on commit ccbe23c

Please sign in to comment.