Skip to content
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

Extract unparsed path from context #207

Open
Nivl opened this issue Apr 14, 2022 · 3 comments
Open

Extract unparsed path from context #207

Nivl opened this issue Apr 14, 2022 · 3 comments

Comments

@Nivl
Copy link

Nivl commented Apr 14, 2022

When extracting a route path using (:compojure/route req) we can retrieve the raw unparsed path. So for example if my path is /hello/:name and a user hits /hello/world, I can retrieve /hello/:name. This is extremely useful for tracing and to capture metrics in general.

Now the issue is that this isn't (doesn't seem?) doable when using a context. For example, given this context:

(context "/nested/:greeting" [_]
           (GET "/world" [_] {:status 200}))

If a user hits /nested/hello/world, we can retreive /nested/hello from the request (in the :context), but not /nested/:greeting.

Our goal is to have the /nested/:greeting/world string available for our telemetry data.

It would be amazing if this could be supported.

@weavejester
Copy link
Owner

The :uri key will give you the full path.

@Nivl
Copy link
Author

Nivl commented Apr 14, 2022

@weavejester :uri would provide the full parsed path. For example instead of providing me with /nested/:greeting/world it would provide /nested/hello/world.

@weavejester
Copy link
Owner

Ah, apologies, I misread and you're right that this isn't currently supported. I would be fine with a PR that adds a :compojure/full-route key to the request map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants