Context paths

You can now configure the context path by calling app.contextPath("/context-path").
Any requests made below the context path will result in a 404. For example:

  • Java
  • Kotlin
Javalin app = Javalin.create()

app.get("/", ctx -> ctx.result("Hello, World"));
val app = Javalin.create().apply {

app.get("/") { ctx -> ctx.result("Hello, World") }
GET localhost:1234/                   // 404
GET localhost:1234/my-path            // 200 (Hello, World)
GET localhost:1234/my-path/           // 200 (Hello, World)
GET localhost:1234/script.js          // 404
GET localhost:1234/my-path/script.js  // 200 (if there is a script.js file in your /public folder)

Any argument to contextPath() will be normalized to the form /path (slash, path, no-slash)

@NotNull annotations

All the Java API’s have had @NotNull added to their method signatures, which should provide better IDE support when programming in Kotlin.

Simple safety refactoring

  • Always check if response is committed before trying to write to it
  • Wrap doHandle() in try-catch