Class: Dragonfly::RoutedEndpoint
- Defined in:
- lib/dragonfly/routed_endpoint.rb
Defined Under Namespace
Classes: NoRoutingParams
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, &block) ⇒ RoutedEndpoint
constructor
A new instance of RoutedEndpoint.
Constructor Details
#initialize(app, &block) ⇒ RoutedEndpoint
Returns a new instance of RoutedEndpoint.
6 7 8 9 |
# File 'lib/dragonfly/routed_endpoint.rb', line 6 def initialize(app, &block) @app = app @block = block end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/dragonfly/routed_endpoint.rb', line 11 def call(env) params = symbolize_keys_of Rack::Request.new(env).params job = @block.call(params.merge(routing_params(env)), @app) Response.new(job, env).to_response rescue Job::NoSHAGiven => e [400, {"Content-Type" => 'text/plain'}, ["You need to give a SHA parameter"]] rescue Job::IncorrectSHA => e [400, {"Content-Type" => 'text/plain'}, ["The SHA parameter you gave (#{e}) is incorrect"]] end |