-
-
Notifications
You must be signed in to change notification settings - Fork 557
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
Javalin 7 API redesign #2091
Comments
Hello, I'm just getting started with Javalin 6. One comment about this:
To me that seems more confusing, instead of less awkward. If "Javalin" is "app", and on the next line outside the anonymous function I try "app.router.get(...)" and it doesn't resolve, it's confusing. Especially when using "val" in Kotlin or "var" in Java where the class isn't explicitly stated, and you have to hover or go exploring to find out what something is. It's less confusing and less awkward if the arbitrary variable names match more closely to their types, like in the earlier example:
This makes it clear to me (again, I'm new) that the Javalin "app" and the JavalinConfig "config" are not the same class. |
Thanks for your feeddback @jbuhacoff, how do you feel about fun main() {
val javalin = Javalin.create { app ->
app.router.get("/hello") { ctx -> ctx.result("Hello, World!") }
}
} |
I didn't notice this before, but for me, calling the config an "app" sounds quite incorrect and confusing as well. If you really don't want to call this |
I agree, it's "app config", which is why I called it
and so on. Singling out this particular xyz-config with the generic name |
Yes it does, because for all of these options you wouldn't hold a reference with the same name, as you would do for your |
But that's completely arbitrary? It's only called |
People might still call it that way, since it is an instance of the Javalin "application". TL,DR: |
The old
|
I think any of these 4 options would be fine, because they give different names to the Javalin instance vs the JavalinConfig instance. This one would be the least changes to existing documentation: val javalin = Javalin.create { app -> Because most of the action is in inside the anonymous function. |
Javalin instance and JavalinConfig APIs
Test for "full" api: https://github.com/javalin/javalin/commit/eef4dcc39d448e5d912bafa947517bb5b34a56eaWe currently have this API:
I've left out a few similar methods and overloads, but all categories should be included.
I think we want to move most of the methods on
Javalin
intoJavalinConfig
. We want to keep the simplicity of the Hello World Example though:With the current router, we have:
Which is not good enough.
Something like:
Could be enough to get rid of the direct methods.
Changing the naming around makes it a bit less awkward:
Bigger example:
With old syntax:
We have several APIs that accept java classes, but no kotlin class overrides. We do have some reified alternatives. We should try to standardize this. Using `MyClass.class` and `MyClass::class` is probably the best approach. We have some issues with reified on interfaces.MyClass::class.java
vsMyclass::class
vs reifiedGetters, setters additive methods
methodName(value)
for setters (including keyed setters).methodName()
for getters (including keyed getters).addMethodName()
for additive operations (can be called multiple times)Different Contexts for before/endpoint/after
Not everything is available in each stage. We should have a BaseContext, and let each stage extend. BeforeContext, EndpointContext, AfterContext. Look at what WsContext does.Fix MultiPartUtil.preUploadFunction
It should not be accessible through singleton.Audit class and method visibility
Lots of unintentionally public stuff nowCreate better exception classes which extend JavalinException
Currently we throw a few RuntimeException, which is a bit lazy. We should fix this.Create wrappers for template engines
javalin-rendering
goes away,javalin-rendering-velocity
(etc) is introducedJavalin vs StartedJavalin
We should separate this.Javalin.create
->Javalin
(.start
->StartedJavalin
)Javalin.createAndStart
->StartedJavalin
Make RateLimitUtil configurable on instance (or make it a plugin)
Current API:Rework events api
@dzikoysk wants to look at this.Fix "matchedPath" (routerPath?)
matchedPath is a bad name, it should be something like routerPathThe text was updated successfully, but these errors were encountered: