From 5714fcf36d778c2a39b7368fa47de808c326ca0c Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 9 Aug 2012 23:45:39 +0200 Subject: [PATCH] Allow turning off Home::Endpoint Home::Endpoint by default redirects GET / request to /docs. This may be desireable when Travis::Api::App is the only app running, but if it's running in front of other app, you may want to keep root for other things. --- lib/travis/api/app.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 542d845f..18fffe26 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -48,13 +48,15 @@ class Travis::Api::App attr_accessor :app - def initialize + def initialize(options = {}) Travis::Api::App.setup @app = Rack::Builder.app do use Rack::Protection::PathTraversal use Rack::SSL if Endpoint.production? Middleware.subclasses.each { |m| use(m) } - Endpoint.subclasses.each { |e| map(e.prefix) { run(e) } } + endpoints = Endpoint.subclasses + endpoints -= [Endpoint::Home] if options[:disable_root_endpoint] + endpoints.each { |e| map(e.prefix) { run(e) } } end end