New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add HTTP::Request#route_uri_pattern that returns URI pattern of matched route. #47129
Conversation
@@ -57,6 +57,8 @@ def self.empty | |||
new({}) | |||
end | |||
|
|||
attr_accessor :route_uri_pattern |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should implement this using the rack env so middleware can also have access to the information. See routes=
for example.
79d6fd8
to
4f1c20b
Compare
@rafaelfranca thanks for the suggestions in your review. I've updated the PR accordingly ❤️ |
@@ -153,6 +153,14 @@ def routes=(routes) # :nodoc: | |||
set_header("action_dispatch.routes", routes) | |||
end | |||
|
|||
def route_uri_pattern # :nodoc: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def route_uri_pattern # :nodoc: | |
def route_uri_pattern |
We want this method to be public API so we need to document it.
8b5b037
to
88346fc
Compare
In the GitHub RoR monolith, we output the route URI pattern in an HTML meta tag in our application layout for analysis purposes. However, our current implementation is quite manual. This change adds an attribute to requests with the URI pattern of the matched route. Co-authored-by: Kate Higa <khiga8@github.com>
cf76b0a
to
3e63c4b
Compare
get_header("action_dispatch.route_uri_pattern") | ||
end | ||
|
||
def route_uri_pattern=(pattern) # :nodoc: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joelhawksley I've opened #47306 but I was thinking we might want to add a test for this if possible? WDYT?
Motivation / Background
In the GitHub RoR monolith, we output the route URI pattern in an HTML meta tag in our application layout for analysis purposes. However, our current implementation is quite manual.
Detail
This change adds an attribute to requests with the URI pattern of the matched route.
Additional information
Co-authored-by: Kate Higa khiga8@github.com
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]