Class: Useless::Rack
- Inherits:
-
Object
- Object
- Useless::Rack
- Defined in:
- lib/useless/rack.rb,
lib/useless/rack/fs.rb,
lib/useless/rack/files.rb,
lib/useless/rack/mongo.rb,
lib/useless/rack/exceptions.rb,
lib/useless/rack/authentication/access_token.rb,
lib/useless/rack/authentication/query_string.rb,
lib/useless/rack/authentication/request_header.rb
Defined Under Namespace
Modules: Authentication Classes: Exceptions, FS, Files, Mongo
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(base = nil, map = nil, &block) ⇒ Rack
constructor
A new instance of Rack.
- #map(pair) ⇒ Object
Constructor Details
#initialize(base = nil, map = nil, &block) ⇒ Rack
Returns a new instance of Rack.
19 20 21 22 23 |
# File 'lib/useless/rack.rb', line 19 def initialize(base = nil, map = nil, &block) @base = base @map = map || {} instance_eval &block if block_given? end |
Instance Method Details
#call(env) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/useless/rack.rb', line 30 def call(env) base = @base map = @map ::Rack::Builder.app do use Low::Rack::Default use Low::Rack::Exceptions use Low::Rack::RequestId use Low::Rack::RackErrors use Low::Rack::LogLevel use Low::Rack::RequestLogger, key: 'useless.logger' use ::Rack::CommonLogger use Useless::Rack::Mongo use Useless::Rack::FS use Useless::Rack::Authentication::QueryString use Useless::Rack::Authentication::RequestHeader use Useless::Rack::Exceptions run Low::Rack::SubdomainMap.new(base, map) end.call(env) end |
#map(pair) ⇒ Object
25 26 27 28 |
# File 'lib/useless/rack.rb', line 25 def map(pair) subdomain, app = pair.first @map[subdomain.to_s] = app.respond_to?(:new) ? app.new : app end |