Class: Dragonfly::Response
Constant Summary collapse
- DEFAULT_FILENAME =
proc{
Instance Method Summary collapse
-
#initialize(job, env) ⇒ Response
constructor
A new instance of Response.
- #served? ⇒ Boolean
- #to_response ⇒ Object
Constructor Details
#initialize(job, env) ⇒ Response
Returns a new instance of Response.
13 14 15 16 |
# File 'lib/dragonfly/response.rb', line 13 def initialize(job, env) @job, @env = job, env @app = @job.app end |
Instance Method Details
#served? ⇒ Boolean
33 34 35 |
# File 'lib/dragonfly/response.rb', line 33 def served? request.get? && !etag_matches? end |
#to_response ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dragonfly/response.rb', line 18 def to_response if !(request.head? || request.get?) [405, method_not_allowed_headers, ["#{request.request_method} method not allowed"]] elsif etag_matches? [304, cache_headers, []] elsif request.head? [200, success_headers.merge(cache_headers), []] elsif request.get? [200, success_headers.merge(cache_headers), job.result] end rescue DataStorage::DataNotFound => e app.log.warn(e.) [404, {"Content-Type" => 'text/plain'}, ['Not found']] end |