Ratpack is a web application library for Java / Groovy published in Apache License v2.
Since Ratpack uses Netty for communication, it operates event-driven like node.js. Therefore, it is possible to realize scalable and high-performance HTTP communication.
Non-blocking communication requires support for asynchronous programming, which Java is not good at.
Ratpack supports this with the Promise
class and also has extensions for RxJava.
One of the development goals of Ratpack is to be "flexible and non-opinioned when integrating with other tools and libraries".
There are extension modules such as ratpack-groovy
, ratpack-guice
, ratpack-jackson
, ratpack-rxjava
, ratpack-session
.
According to the official page, the following are listed as ** not ** goals for Ratpack:
Hello World
build.gradle
dependencies {
compile 'io.ratpack:ratpack-core:1.5.1'
}
Sample.java
public final class Sample {
public static void main( String[] args ) throws Exception {
RatpackServer.start( server -> server
.handlers( chain -> chain.get( ctx -> ctx.render( "hello, world" ) ) ) );
}
}
As you can see, it is made on the premise that lambda expressions are used a lot, so if you are not familiar with lambda expressions, please learn it.
I was sick of Spring and was looking for an alternative library and came across Ratpack. However, there was not much information in Japanese, and even if it was, it was Groovy instead of Java, and the official documentation was sometimes difficult to understand. Therefore, I decided to write this article series, hoping to support those who are going to use Ratpack from now on.
In the next post, I'll look at how to use Ratpack in detail.
Recommended Posts