You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe your issue
When I was updating my Request Logger to log WebSockets, I noticed that the Ws{{Action}}Context.matchedPath() was returning * instead of /ws that I would've expected.
For HTTP requests, via the Context class, .matchedPath() would return the endpoint path that you registered via:
when being called from inside of the RequestLogger, meaning, that the Context.matchedPath() result is /resource/{resource_id}/, not *.
The Request Logger is always going to match on ALL requests, it's kind of its point, of which is how it's getting the * value in the first place. So I'm more confused as to why the implementation for WebSockets ever uses * as the matchedPath as it's never useful to the end user in the first place.
To @tipsy, this feels more like an API design flaw in the naming conventions and is something that is up for discussion in Javalin 7 over at #2091, but to me as a user, it sounds more like an implementation flaw that wasn't caught or questioned early on simply due to the fact that not a lot of Javalin users use the WebSockets functionality in the first place. How this issue is determined (api flaw or implementation flaw) isn't all that important, just outlining the confusion is important here.
I have raised a separate issue for making this getter method nicer to read for Java developers.
What would be nice, would be to have a Ws{{Action}}Context.path() method, but for metric logging (eg: Prometheus) I need the matched path, so I'm still reliant on the upgrade context for my usage. You typically want the full path .path() for console logging, but then the matchedPath for timeseries.
The text was updated successfully, but these errors were encountered:
LoonyRules
changed the title
Confusing WsContext.matchedPath() functionality
Confusing Ws{{Action}}Context.matchedPath() functionality
Apr 7, 2024
Describe your issue
When I was updating my Request Logger to log WebSockets, I noticed that the
Ws{{Action}}Context.matchedPath()
was returning*
instead of/ws
that I would've expected.For HTTP requests, via the
Context
class,.matchedPath()
would return the endpoint path that you registered via:when being called from inside of the RequestLogger, meaning, that the
Context.matchedPath()
result is/resource/{resource_id}/
, not*
.The Request Logger is always going to match on ALL requests, it's kind of its point, of which is how it's getting the
*
value in the first place. So I'm more confused as to why the implementation for WebSockets ever uses*
as the matchedPath as it's never useful to the end user in the first place.To @tipsy, this feels more like an API design flaw in the naming conventions and is something that is up for discussion in Javalin 7 over at #2091, but to me as a user, it sounds more like an implementation flaw that wasn't caught or questioned early on simply due to the fact that not a lot of Javalin users use the WebSockets functionality in the first place. How this issue is determined (api flaw or implementation flaw) isn't all that important, just outlining the confusion is important here.
What I really wanted for my request logging was:
I have raised a separate issue for making this getter method nicer to read for Java developers.
What would be nice, would be to have a
Ws{{Action}}Context.path()
method, but for metric logging (eg: Prometheus) I need the matched path, so I'm still reliant on the upgrade context for my usage. You typically want the full path.path()
for console logging, but then the matchedPath for timeseries.The text was updated successfully, but these errors were encountered: