class Grape::Middleware::OinkMiddleware

Public Instance Methods

before() click to toggle source
# File lib/grape/middleware/oink_middleware.rb, line 4
def before
  options = env['api.endpoint'].try(:options)

  if options.present?
    controller = options[:for].to_s.split("::").last.underscore
    action = options[:path].try(:first)
    if action
      action = action.to_s
      action = action.gsub("/", "sl_")
      action = action.gsub(":", "col_")
    end
    method = options[:method].try(:first)
    env_action = "#{action}_#{method}"
    env['action_dispatch.request.parameters'] = {'controller' => controller, 'action' => env_action}
  end
end