blob: 50fe176946418fb80af0c94a619002764f45a5e1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# frozen_string_literal: true
require "rails/application_controller"
require "action_dispatch/routing/inspector"
class Rails::InfoController < Rails::ApplicationController # :nodoc:
prepend_view_path ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH
layout -> { request.xhr? ? false : "application" }
before_action :require_local!
def index
redirect_to action: :routes
end
def properties
respond_to do |format|
format.html do
@info = Rails::Info.to_html
@page_title = "Properties"
end
format.json do
render json: Rails::Info.to_json
end
end
end
def routes
if path = params[:path]
path = URI.parser.escape path
normalized_path = with_leading_slash path
render json: {
exact: match_route { |it| it.match normalized_path },
fuzzy: match_route { |it| it.spec.to_s.match path }
}
else
@routes_inspector = ActionDispatch::Routing::RoutesInspector.new(_routes.routes)
@page_title = "Routes"
end
end
private
def match_route
_routes.routes.select { |route|
yield route.path
}.map { |route| route.path.spec.to_s }
end
def with_leading_slash(path)
("/" + path).squeeze("/")
end
end
|