Web framework: Javalin 4.0 brings support for JDK 16 and Kotlin 1.5

Published by: MRT

Published on:

Web framework: Javalin 4.0 brings support for JDK 16 and Kotlin 1.5

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

In version 4.0, the syntax for path parameters has changed from :param to {param} changed. The syntax is also new <param>that allows slashes in path parameters. A single path segment can now contain both static and dynamic parts as well as several path parameters, as the migration guide from version 3 shows:

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/<subpaths>/leaf") // new (will match /root/1/2/3/leaf)

Javalin 4.0 also revises the configuration options for the options for static files. By removing global options, these can now be added via Static File Handler 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;
});

The testing module is another new feature in version 4.0 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 stand out from similar frameworks by being designed for Java and Kotlin interoperability rather than offering different versions for the programming languages. In addition, Javalin has supported the OpenAPI specification since version 3.0 with the help of a plug-in.

The Javalin homepage provides an introduction both 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.


(May)

Article Source

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