137

Javalin 1.2.0 - Custom jetty handlers - Javalin: Simple REST APIs for Java and K...

 6 years ago
source link: https://javalin.io/news/2017/12/02/javalin-1.2.0-released.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Javalin 1.2.0 released

Custom jetty handlers (Dec 2, 2017)
What's Javalin? Javalin is a very lightweight Java and Kotlin web framework which focuses on simplicity and Java/Kotlin interoperability. Read more on our landing page.

Custom jetty handlers

Javalin 1.2.0 introduces the possibility of adding custom jetty handlers, such as StatisticsHandler and RequestLogHandler.
You can configure your embedded jetty-server with a handler-chain (example), and Javalin will attach it’s own handlers to the end of this chain.

  • Kotlin
val statisticsHandler = StatisticsHandler()

Javalin.create().apply {
    embeddedServer(EmbeddedJettyFactory({
        Server(queuedThreadPool).apply {
            handler = statisticsHandler
        }
    }))
}.start();

Doing this will allow you to integrate Javalin with for example prometheus easily, by exposing statistics collected by the StatisticsHandler.
There’s even a tutorial to show you how that’s done: /tutorials/prometheus-example

EventManager cleanup

There was a bug in the Event data class, where properties were declared as var instead of val. The Javalin val was nullable for no apparent reason, so that’s been fixed too.

Kotlin 1.2.0

Kotlin has been bumped to 1.2.0


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK