asad.awadia
03/21/2020, 3:15 PMtipsy
03/21/2020, 6:51 PMasad.awadia
03/21/2020, 7:38 PMtipsy
03/21/2020, 7:39 PMasad.awadia
03/21/2020, 7:41 PMtipsy
03/21/2020, 7:44 PMasad.awadia
03/21/2020, 7:46 PMtipsy
03/21/2020, 7:48 PMfun main() {
val app = Javalin ...
val userService = UserService(deps)
val smsService = SmsService(deps)
userService.addRoutes(app)
smsService.addRoutes(app)
}
ApiBuilder
class in javalin uses a temporary static variable (which is only valid inside the scope of a routes
call), you could potentially build your own fancy DSL for this (although i don't really recommend it)asad.awadia
03/21/2020, 7:51 PMtipsy
03/21/2020, 7:52 PMasad.awadia
03/21/2020, 7:53 PMtipsy
03/21/2020, 7:54 PMfun handleWs(ws: WsHandler) {
ws.onConnect...
ws.onClose...
}
class MyService{
fun addRoutes(app: Javalin) {
app.get(path ::myGetHandler)
<http://app.ws|app.ws>(path ::myWsHandler)
}
}
asad.awadia
03/21/2020, 11:05 PMtipsy
03/22/2020, 7:59 AM