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.
This commit is contained in:
Piotr Sarnacki 2012-08-09 23:45:39 +02:00
parent 674ed5c34c
commit 5714fcf36d

View File

@ -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