Important: This news article covers an old version of Javalin (v1.5.0). The current version is v6.4.0.
See the documentation page for up-to-date information.

WebsSocket improvements

One of the most requests WebSocket features has been the ability to use dynamic paths, like /:param. This has finally been added:

ws("/chat/:channel") { ws ->
    ws.onMessage { session, message ->
        val channel = session.param("channel")
        broadcastMessage(channel, message)
    }
}

More convenience methods for extracting information from the upgrade-request were also added:

session.paramMap() // get all param key/values as map
session.header("key") // get a header
session.headerMap() // get all header key/values as map
session.host() // get request host

Route overview

You can now generate an overview of all the mapped paths in your application and host it on a path of your choice:

val app = Javalin.create().apply {
    enableRouteOverview("route-overview")
}

The route-overview will show the verb, the path, the function/field/class handling the request, and any roles attached to the handler:

Route overview

Multipart fields

Previously the Apache FileUpload dependency was required in order to receive uploaded files, and multipart-fields simply didn’t work. You can now access multipart-fields via the normal form-param function (ctx.formParam("name")), and Apache FileUpload is no longer necessary in order to receive uploaded files (the public API remains unchanged).

Misc/Bugfixes

  • Jetty was bumped to 9.4.9.v20180320 which was released very recently. There were no breaking changes.
  • Fixed some minor bugs in path-prefixing in ApiBuilder