days
0
-13
-9
hours
-1
-3
minutes
0
-3
seconds
-2
-3
search
New minor version for Javalin

Javalin 3.7 adds rate limiting and case insensitive path matching

Maika Möbus
Javalin
© Shutterstock / 1933bkk

The lightweight Java and Kotlin web framework Javalin is updated on a regular basis, and this year’s first minor release is version 3.7. It offers additional features such as rate limiting and brings back a function you may have used in previous versions. Let’s take a closer look.

Javalin 3.7 has been released, and it has new features and bug fixes on board. Because Javalin follows semantic versioning, there is no need to worry about breaking changes in this minor version. The web framework for Java and Kotlin is developed to be lightweight and simple to use, and is meant to be more of a library than a framework.

SEE ALSO: A deep dive into the Jakarta EE 9 Release Plan

What’s new in Javalin 3.7?

The new Javalin release comes with rate limiting. For this, a simple util class has been added. Different endpoints can have different rate limits, as every rate limiter is independent.

You can call the new util class in the beginning of endpoint handler functions, which looks like this:


app.get("/") { ctx ->
RateLimit(ctx).requestPerTimeUnit(5, TimeUnit.MINUTES) // throws if rate limit is exceeded
ctx.status("Hello, rate-limited World!")
}

If you miss case insensitive matching that was available in Javalin 2.x, you can now use the new plugin RedirectToLowercasePathPlugin. Here’s how to install it:

config.registerPlugin(RedirectToLowercasePathPlugin())

The plugin redirects requests with uppercase or mixcase paths to lowercase paths. This is applied only to static URL fragments. For example, /Users/John is redirected to /users/John if the endpoint is /users/:userId.

Other changes and bug fixes

New features in Javalin 3.7 also include support for dynamic single page handlers and added path overload for the JavalinVue#rootDirectory method. One of the fixed bugs is that config.enforceSsl now takes load balancers into account.

SEE ALSO: Java 14: JDK 14 enters Rampdown Phase Two

The official website offers further details on Javalin 3.7.

Author
Maika Möbus
Maika Möbus has been an editor for Software & Support Media since January 2019. She studied Sociology at Goethe University Frankfurt and Johannes Gutenberg University Mainz.

Leave a Reply