Method: Rack::Builder#to_app

Defined in:
lib/cloudkit/rack/builder.rb

#to_appObject

Extends Rack::Builder’s to_app method to detect if the last piece of middleware in the stack is a CloudKit shortcut (contain or expose), adding a default developer page at the root and a 404 everywhere else.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cloudkit/rack/builder.rb', line 8

def to_app
  default_app = lambda do |env|
    if (env['PATH_INFO'] == '/')
      Rack::Response.new(welcome).finish
    else
      Rack::Response.new('not found', 404).finish
    end
  end
  @ins << default_app if @last_cloudkit_id == @ins.last.object_id
  cloudkit_to_app
end