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

App extensions

You can now create app-extensions by calling app.register(appExtension). The Extension interface is a simple lambda with access to the current Javalin app:

Javalin.create()
    .register(app -> { ... }) // register lambda
    .register(new ExtensionClass(...)); // ExtensionClass must implement Extension

You can (for example) create a DosFilter that you use across multiple Javalin apps, and add it to each app by calling app.register(new DosFilter()).

The feature is inspired by the register function in Sinatra: http://sinatrarb.com/extensions.html

Single-page mode improvements

  • You can now use external (non classpath) files for your single-page entrypoint (index.html)
  • Single-page entry point (index.html) is no longer cached if host is localhost

Bugfixes and misc

  • You can now call ctx.resultString() in request loggers (after the response has been written).
  • You can now set the context-path in EmbeddedJavalin
  • Static resource handling now has a ResourceHandler interface, so you can use your own resource handler if you’re extending Javalin
  • An error is now logged if user attempts to read request body twice, and body is not cached
  • Improved custom handling of HttpResponseException