class Lurker::Request

Constants

PREFIX

Public Class Methods

build_from_action_dispatch(request) click to toggle source
# File lib/lurker/request.rb, line 18
def self.build_from_action_dispatch(request)
  new(
    verb: request.method,
    endpoint_path: route_name(request),
    path_info: request.path_info,
    path_params: request.env["#{PREFIX}.path_parameters"].stringify_keys.except('format'),
    query_params: request.env["#{PREFIX}.query_parameters"],
    payload: request.env["#{PREFIX}.request_parameters"].merge(
      request.env["#{PREFIX}.query_parameters"]
    ).stringify_keys.except('action', "controller", 'format', '_method')
  )
end
reject_internal(hash) click to toggle source
# File lib/lurker/request.rb, line 31
def self.reject_internal(hash)
end
route_name(request) click to toggle source
# File lib/lurker/request.rb, line 34
def self.route_name(request)
  if defined? Rails
    Rails.application.routes.router.recognize(request) do |route, _|
      return route.path.spec.to_s.sub('(.:format)', '')
    end
    raise NonroutableRequest.new("Cannot find named route for: #{request.env['HTTP_HOST']}#{request.path_info}")
  end
end