URLs generated by wrap-trace middleware should be aware of the context#142
URLs generated by wrap-trace middleware should be aware of the context#142ray1729 wants to merge 1 commit intoclojure-liberator:masterfrom
Conversation
…t under which it is deployed.
|
Thanks for the PR. I will have to investigate as I do not yet fully understand the implications of the issue and the PR. |
ordnungswidrig
left a comment
There was a problem hiding this comment.
Thanks for the patch which sounds reasonable. I've left some comment regarding the dynamic binding. Also, I think having some tests would be helpful to ensure no new bugs have been introduced.
| [:span " at " [:span (h d)] " " [:span "(" (seconds-ago d) "s ago)"]]]) @logs)])]))) | ||
|
|
||
| (defn css-url [] (str (with-slash mount-url) "styles.css")) | ||
| (defn css-url [] (str (with-slash (str *context* mount-url)) "styles.css")) |
There was a problem hiding this comment.
Instead of dynamic binding I'd prefer an explicit argument.
| ""])] | ||
| [:body | ||
| [:a {:href mount-url} "List of all traces"] | ||
| [:a {:href (str *context* mount-url)} "List of all traces"] |
There was a problem hiding this comment.
Use the :context from the request instead and (let [base-url (str (:context request) "/" mount-url))] ...)
| (if (nil? r) [:em "nil"] (h (pr-str r)))]) log)] | ||
| [:div {:style "text-align: center;"} | ||
| [:object {:id "trace" :data (str mount-url "trace.svg") :width "90%" | ||
| [:object {:id "trace" :data (str *context* mount-url "trace.svg") :width "90%" |
| [:body [:h1 "Liberator Request Trace #" id " not found."] | ||
| [:p "The requested trace was not found. Maybe it is expired."] | ||
| [:p "You can access a " [:a {:href mount-url} "list of traces"] "."]]))) | ||
| [:p "You can access a " [:a {:href (str *context* mount-url)} "list of traces"] "."]]))) |
| [:ol (map (fn [[id [d {:keys [request-method uri]} log]]] | ||
| [:ul | ||
| [:a {:href (h (str (with-slash mount-url) id))} | ||
| [:a {:href (h (str (with-slash (str *context* mount-url)) id))} |
| given trace id" | ||
| [id] | ||
| (str (with-slash mount-url) id)) | ||
| (str (with-slash (str *context* mount-url)) id)) |
|
@ray1729 I realize that this PR is a little old, but still valuable. If you don't want to participate in it any more simply let me know and I'm going to clean it up myself :-) |
The liberator.dev/wrap-trace middleware was generating URLS at /x-liberator/requests/ which only works when the handler is installed at the root context. This pull request adds support for handlers deployed under any context, and generates URLs relative to the context.