Class: Triboelectric::Static
- Inherits:
-
Object
- Object
- Triboelectric::Static
- Defined in:
- lib/triboelectric/static.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Static
constructor
A new instance of Static.
Constructor Details
#initialize(app, options = {}) ⇒ Static
5 6 7 8 9 10 11 |
# File 'lib/triboelectric/static.rb', line 5 def initialize(app, = {}) Uploader.upload() if .fetch(:upload, true) @app = app @static = Rack::Static.new(@app, ) @bucket = [:bucket] @root = [:root] end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/triboelectric/static.rb', line 13 def call(env) return @app.call(env) unless @static.can_serve(env[Rack::PATH_INFO]) status, headers, body = @static.call(env) if (object = get_object(env, status)) headers[Rack::CONTENT_TYPE] = object.content_type headers[Rack::CONTENT_LENGTH] = object.content_length status = 200 body = object.body end [status, headers, body] end |