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

Avoid infinite recursion when there is a redirect #338

Merged
merged 1 commit into from
Feb 28, 2015
Merged
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
7 changes: 4 additions & 3 deletions lib/apipie/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ def rails_routes(route_set = nil)

# the app might be nested when using contraints, namespaces etc.
# this method does in depth search for the route controller
def route_app_controller(app, route)
def route_app_controller(app, route, visited_apps = [])
visited_apps << app
if app.respond_to?(:controller)
return app.controller(route.defaults)
elsif app.respond_to?(:app)
return route_app_controller(app.app, route)
elsif app.respond_to?(:app) && !visited_apps.include?(app.app)
return route_app_controller(app.app, route, visited_apps)
end
rescue ActionController::RoutingError
# some errors in the routes will not stop us here: just ignoring
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
apipie
end
root :to => 'apipie/apipies#index'
match '(/)*path' => redirect('http://www.example.com'), :via => :all
end