3 ms·
Regarding 2, you can actually bind routes to instance methods: var obj = new SomeObjectWithHandlerMethods(dependency); var app = Javalin.create().get("/",
by breakpete 3y ago
Regarding 2, you can actually bind routes to instance methods:
var obj = new SomeObjectWithHandlerMethods(dependency);
var app = Javalin.create().get("/", obj::handlerMethod).start();
Edit: For 4, Javalin 6 also has some documentation regarding Servlets here: https://javalin.io/documentation#adding-other-servlets-and-filters-to-javalin https://javalin.io/documentation#adding-other-servlets-and-f...
- derefr 3y agoStrange — I swear this wasn't the case. I and several other devs tried for a good three weeks to get Javalin to accept such route bindings. This was a year or two ago, though. Maybe the interface type for a handler function was changed in some more recent version of Javalin?
- tip-alt 3y agoIt's been a SAM interface since 2017 and basically hasn't changed at all.
- breakpete 3y agoNot sure about the older versions of Javalin, but from my experience with v5+ it just uses regular Single Abstract Method conversion for the Handler interface, which has a single method with just one parameter (the Context).