Web framework: Javalin 4.0 supports JDK 16 and Kotlin 1.5


The open source Javalin web framework is available in version 4.0. More than two years have passed since the previous major version Javalin 3.0, and therefore a lot has happened in the framework for Java and Kotlin – among others, all Javalin modules with language versions Java 16 and Kotlin 1.5 can now be used.

In version 4.0, the syntax for path parameters changed from :param at {param} amended. The syntax is also new which allows forward slashes in path parameters. A single path segment can now contain both static and dynamic parts as well as multiple path parameters, as shown in version 3 migration guide:

get("/:param", ...) // old
get("/{param}", ...) // new

get("/:param-suffix", ...) // invalid
get("/{param}-suffix", ...) // new

get("/files/:filename.:extension", ...) // invalid
get("/files/{filename}.{extension}", ...) // new

get("/root/:subpaths/leaf") // old (will only match /root/1/leaf)
get("/root//leaf") // new (will match /root/1/2/3/leaf)

Javalin 4.0 is also revising the configuration options for static file options. By removing the global options, these can now be added through the static file manager and can be configured in a way known in Javalin:

config.addStaticFiles(staticFiles -> {
    staticFiles.aliasCheck = ContextHandler.AliasCheck((path, resource) -> !path.endsWith(".txt"));
    staticFiles.directory = "src/test/external/";
    staticFiles.location = Location.EXTERNAL;

Another new feature of version 4.0 is the test module javalin-testtools, advanced customization options for the Validatorclass as well as the replacement of JavalinJson through a JsonMapper-Interface with four optional methods.

Javalin is said to be lightweight and stands out from similar frameworks by being designed for Java and Kotlin interoperability rather than offering different versions for programming languages. In addition, Javalin supports the OpenAPI specification since version 3.0 using a plug-in.

The Javalin home page provides an introduction official and community tutorials. According to the development team, the open source framework has around 130,000 monthly downloads.

More information on Javalin 4.0 can be found in a blog post.


Source of the article

Disclaimer: This article is generated from the feed and not edited by our team.


Comments are closed.