class Goliath::Chimp::Rack::Validation::RequiredRoutes
Attributes
route_key[R]
select_routes[R]
Public Class Methods
new(app, key, routes = {})
click to toggle source
# File lib/goliath/chimp/rack/validation/required_routes.rb, line 8 def initialize(app, key, routes = {}) @app = app @route_key = key @select_routes = routes end
Public Instance Methods
call(env)
click to toggle source
# File lib/goliath/chimp/rack/validation/required_routes.rb, line 14 def call env if endpoint = env['routes'][route_key] rescue nil route, required = select_routes.detect{ |name, required| name === endpoint } return validation_error(400, "A #{required} route is required for #{endpoint}") if required && env['routes'][required].nil? @app.call env else @app.call env end end