Important: This news article covers an old version of Javalin (v0.3.5).
The current version is v6.3.0.
See the documentation page for up-to-date information.
See the documentation page for up-to-date information.
ctx.mapQueryParams()
This feature is mostly useful for Kotlin users, as it allows for very neat query-param declaration with destructuring and elvis-throws:
app.post("/new-user") { ctx ->
val (name, email) = ctx.mapQueryParams("name", "email") ?: throw MissingQueryParamException()
}
ctx.anyQueryParamNull()
This is band-aid for Java developers who can’t use ctx.mapQueryParams()
,
at least you can make sure that your query-params are present:
app.post("/new-user", ctx ->
if (ctx.anyQueryParamNull("name", "email")) {
throw new MissingQueryParamException();
}
});
Minor change in before
/after
Previously before
and after
used /*
as path when called pathless (like before(handler)
).
This has been changed to *
, in order to include the root path (/
).