-
Notifications
You must be signed in to change notification settings - Fork 256
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 a full-route key to the request map #210
Conversation
Hi @weavejester, could you take a look at this PR when you have a chance? We decided to attach meta info to the compiled route because we don't want to change We are not entirely sure what the full syntax is of Let me know if you have any comments, thank you! |
This looks rather complex for what it attempts to achieve. I notice that there's already a PR, #202, for adding the context route to the request map. Would that solve the issue? |
Thanks for the prompt reply. Yes, #202 would solve the issue. It seems that it's fine to change |
Commit messages of this repository should follow the seven rules of a great Git commit message, as mentioned in the project's contributing guidelines. It looks like there's a few issues with the commit messages in this pull request:
|
6a2a8a7
to
f185750
Compare
@weavejester I've updated my PR to pass the |
@weavejester Sorry for pestering you again, given that no updates on #202, can we get this PR across the line if you have a chance? |
I got distracted by some other PRs - apologies for letting this one slip. I notice there's some formatting changes that look like they've accidentally crept in. Can you ensure the commit contains only the changes relevant to the feature being implemented? |
7295b9c
to
2dc42f8
Compare
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.
Can you separate out the context feature into another PR?
src/compojure/core.clj
Outdated
@@ -261,7 +269,8 @@ | |||
(-> request | |||
(assoc-route-params (decode-route-params params)) | |||
(assoc :path-info (if (= subpath "") "/" subpath) | |||
:context (remove-suffix uri subpath)))))) | |||
:context (remove-suffix uri subpath)) | |||
(update :compojure/context-path (fn [ctx] (str ctx context-path))))))) |
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.
Could be simplified to:
(update :compojure/context-path str context-path)
test/compojure/core_test.clj
Outdated
@@ -38,7 +38,7 @@ | |||
(assoc :params {:y "bar"}))] | |||
((GET "/:x" [x :as r] | |||
(is (= x "foo")) | |||
(is (= (dissoc r :params :route-params :compojure/route) | |||
(is (= (dissoc r :params :route-params :compojure/route :compojure/full-route) |
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.
Keep lines within 80 characters, please.
src/compojure/core.clj
Outdated
@@ -134,9 +134,17 @@ | |||
(defn- wrap-route-info [handler route-info] | |||
(fn | |||
([request] | |||
(handler (assoc request :compojure/route route-info))) | |||
(let [full-route (str (:compojure/context-path request) (second route-info))] |
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.
I think in another PR I suggested :compojure/route-context
. Also better to use destructuring outside the fn rather than second
.
2dc42f8
to
39c4a7d
Compare
This provides access to the full route that contains the common prefix. The full-route info is added to the :compojure/full-route key in the request map. We use :compojure/route to get the route info and add it to the attributes of our metrics and traces, but when compojure.core/context is used, we are not able to get the parameters that are not instantiated. This change adds :compojure/full-route key that serves similarly as the existing :compojure/route does - the only difference is that the new key has a common prefix. Co-authored-by: Liam Chen <[email protected]> Co-authored-by: Claire Alvis <[email protected]>
39c4a7d
to
5abd2eb
Compare
It looks good, but it still needs to be separated out into a "full context" PR and "full route" PR, as I mentioned in my previous review. |
I've thought about this a little, and I think it's sufficient to have |
Yes, that's fair. Having the I am happy to close this PR. Thanks! |
Could you push a new release when you have a chance? |
This provides access to the full route that contains the common prefix.
The full-route info is added to the
:compojure/full-route
key in therequest map.
We use
:compojure/route
to get the route info and add it to theattributes of our metrics and traces, but when
compojure.core/context
is used, we are not able to get the parameters that are not
instantiated. This change adds
:compojure/full-route
key that servessimilarly as the existing
:compojure/route
does - the only differenceis that the new key has a common prefix.
Close #207