Class: EndPointBlank::Commands::RoutePatternFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/end_point_blank/commands/route_pattern_finder.rb

Class Method Summary collapse

Class Method Details

.find(request) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/end_point_blank/commands/route_pattern_finder.rb', line 6

def self.find(request)
  return nil unless defined?(::Rails)

  matched = nil
  ::Rails.application.routes.router.recognize(request) do |route, _params|
    matched = route.path.spec.to_s
    break
  end
  matched
rescue StandardError => e
  EndPointBlank.logger.debug("Error finding route pattern: #{e.message}")
  nil
end