days
-1
-2
hours
-1
-1
minutes
-5
-5
seconds
-5
-1
search
It's a framework, it's a library, it's Javalin!

Javalin 2.0 is here: This lightweight web framework for Kotlin and Java developers just got better

Gabriela Motroc
Javalin
© Shutterstock / Andrii Oleksiienko

Javalin, a very lightweight web framework for Kotlin and Java, has just reached a very important milestone: 2.0.0 stable is out. This release brings a lot of improvements and major changes. Let’s have a look!

We first laid eyes on Javalin last year, when it reached v1.0.0 stable. The first Javalin version was released in May 2017 so they are moving pretty fast!

This very lightweight web framework for Kotlin and Java was inspired by Sparkjava and koa.js, according to the blog post announcing the 1.0 release. Javalin is written in Kotlin “with a few functional interfaces written in Java. This was necessary to provide an enjoyable and near identical experience for both Kotlin and Java developers.”

All of these web frameworks are inspired by the modern micro web framework grandfather: Sinatra, so if you’re coming from Ruby then Javalin shouldn’t feel too unfamiliar.

If you want to read more about its features or see how it works, read this article

Javalin 2.0

A lot has changed since Javalin 1.7; First, you should know that most of the changes are internal, according to the blog post announcing the new version. Second, “some abstraction layers have been removed and the WebSocket implementation and the test-suite have been completely rewritten.”

Here is a quick overview of the major changes:
  • They’ve added ETag support and a method for auto-generating ETags
  • They’ve added a RequestLogger interface ({ ctx, executionTime -> ...})
  • They’ve added the option to return 405 instead of 404, listing available methods for the path
  • They’ve added a set of default responses, so you can throw BadRequestResponse() (optional message)
  • They’ve added a CrudHandler to remove some boilerplate from creating standard CRUD APIs
  • They’ve added support for WebJars (https://www.webjars.org)
  • They’ve improved support for Single Page Applications
  • They’ve improved exception handling for async requests
  • All JSON and Template functionality has been modularized so you can easily plug in your own mappers/rendering engines.
  • All Template functionality has been moved into a single ctx.render() function which uses the correct engine based on the file extension
  • All requests run through an AccessManager now (the default implementation is NOOP)
  • URL matching is now case-insensitive by default (call app.enableCaseSensitiveUrls() if you must)
  • Javalin now has a pac4j implementation
  • Some default values have been changed

But that’s not all. The list of quality of life improvements is pretty impressive and includes the following: functions returning List instead of Array, returning empty collections instead of null, better default values and package structure, fixing visibility from Java, etc. 

If you’d like to migrate from Javalin 1.x to 2.0, you’ll need this guide

Last but not least, if you want to contribute to the project, head on over to GitHub.

    DevOpsCon Whitepaper 2018

    Free: BRAND NEW DevOps Whitepaper 2018

    Learn about Containers,Continuous Delivery, DevOps Culture, Cloud Platforms & Security with articles by experts like Michiel Rook, Christoph Engelbert, Scott Sanders and many more.

asap

Author
Gabriela Motroc
Gabriela Motroc is editor of JAXenter.com and JAX Magazine. Before working at Software & Support Media Group, she studied International Communication Management at the Hague University of Applied Sciences.

Leave a Reply

Be the First to Comment!

avatar
400
  Subscribe  
Notify of