class Goliath::Chimp::Rack::Validation::RouteHandler
Attributes
handler_map[R]
route_key[R]
Public Class Methods
new(app, key, map = {})
click to toggle source
# File lib/goliath/chimp/rack/validation/route_handler.rb, line 8 def initialize(app, key, map = {}) @app = app @route_key = key @handler_map = map end
Public Instance Methods
call(env)
click to toggle source
# File lib/goliath/chimp/rack/validation/route_handler.rb, line 14 def call env endpoint = env['routes'][route_key] rescue nil name, handler = handler_map.detect{ |name, handler| name === endpoint } if handler env['handler'] = handler @app.call env else validation_error(400, "No handler found for #{route_key} <#{endpoint}>") end end