Javalin 3.7 adds rate limiting and case insensitive path matching

Share
  • January 20, 2020

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.

The post Javalin 3.7 adds rate limiting and case insensitive path matching appeared first on JAXenter.

Source : JAXenter