javalin / javalin

A simple and modern Java and Kotlin web framework

Home Page:https://javalin.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Ws{{Action}}Context` classes do not have a pretty `getUpgradeContext()` method.

LoonyRules opened this issue · comments

Describe your issue
The WsConnectContext, WsCloseContext, WsErrorContext, WsMessageContext, and WsBinaryMessageContext classes do not have a pretty way to retrieve the Context that was used during the Upgrade request via the Java Api.

The current usage is:

public void onWsConnect(final @NotNull WsConnectContext ctx) {
  final Context upgradeContext = ctx.getUpgradeCtx$javalin();
  
  // ... do something with the upgradeContext, like `upgradeContext.path()`.
}

but I'd prefer for the usage to be:

public void onWsConnect(final @NotNull WsConnectContext ctx) {
  final Context upgradeContext = ctx.getUpgradeCtx();
  
  // ... do something with the upgradeContext, like `upgradeContext.path()`.
}

So this change is purely a aesthetic request, the underlying functionality should not change.

The current upgradeContext property is marked as internal - it means that it shouldn't be visible for you in the first place, so as a root cause I'd mark this as a bug, because it's missing the @JvmSynthetic annotation. If we'd like to open that part of the API, it might be good idea to investigate the pros/cons of doing this, because maybe it'd make more sense to expose only some particular functions like e.g. mentioned path() - that's the approach we already use for half of the methods in this class.

Ah yeah @tipsy did mention this in Discord but I just forgot to mention that here. Feel free to adjust this to be a Bug then, with another Issue span off discussing the lack of API method for Ws related contexts if that'd how you'd like to manage this? :)

The current upgradeContext property is marked as internal - it means that it shouldn't be visible for you in the first place, so as a root cause I'd mark this as a bug,

I agree that this is a bug, but unfortunately we can't add this annotation now (the method has been public for years). So I chose feature request rather than bug.