Rapidoid - Extremely Fast, Simple and Powerful Java Web Framework!

Open source (Apache license). View benchmark... Community: [email protected]

Rapidoid consists of several modules which can be used separately or together:
Add rapidoid-web as Maven dependency:
<dependency>
    <groupId>org.rapidoid</groupId>
    <artifactId>rapidoid-web</artifactId>
    <version>5.4.6</version>
</dependency>
docker run rapidoid --help
Module rapidoid-web

rapidoid-http-server + rapidoid-gui + goodies

  • The high-level API is built on top of Rapidoid HTTP server, provides many advanced features for building modern POJO-based web applications.
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
NoBullshit.java
@Controller
public class NoBullshit {
 
    @GET
    public String hello() {
        return "Hello, world!";
    }
 
}
GET /hello
"Hello, world!"
POST /hello
404 Not found!

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /hello main json
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
SubUrlParams.java
@Controller
public class SubUrlParams {
 
    @GET("/hey/{name}/{age:\\\\d+}")
    public String hey(String name, int age) {
        return U.frmt("Hey %s (%s)", name, age);
    }
 
    @POST("/size/{s}")
    public int size(String s) {
        return s.length();
    }
 
}
GET /hey/Joe/50
"Hey Joe (50)"
GET /hey/You!/123
"Hey You! (123)"
POST /size/abc
3

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /hey/{name}/{age:\d+} main json
POST /size/{s} main json
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
TextTools.java
@Controller
public class TextTools {
 
    @GET("/upper/{s}")
    public Map<String, String> upper(String s) {
        String big = s.toUpperCase();
        return U.map("normal", s, "big", big);
    }
 
    @POST
    public String[] parts(String text) {
        return text.split("-");
    }
 
}
GET /upper/abc
{"normal":"abc","big":"ABC"}
POST /parts {"text":"just-some-words"}
["just","some","words"]

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
POST /parts main json
GET /upper/{s} main json
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
Book.java
public class Book {
 
    public String title = "Untitled";
 
    private int year;
 
    public int getYear() {
        return year;
    }
 
    public void setYear(int year) {
        this.year = year;
    }
}
EasyBeans.java
@Controller
public class EasyBeans {
 
    @GET
    public Book echo(Book book) {
        return book;
    }
 
}
GET /echo?year=2012&title=Abc
{"title":"Abc","year":2012}
GET /echo?year=2015
{"title":"Untitled","year":2015}

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /echo main json
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
NamedParams.java
@Controller
public class NamedParams {
 
    @GET
    public int sum(int x, @Param("y") int z) {
        return x + z;
    }
 
}
GET /sum?x=1&y=2
3
GET /sum?y=10&x=5&z=12345
15

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /sum main json
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
Hello.java
@Controller
public class Hello {
 
    @Page("/")
    public String hello() {
        return "Hello, world!";
    }
 
}
GET /
Hello, world!
POST /
Hello, world!

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET POST / main html index
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
YourName.java
@Controller
public class YourName {
 
    @Page("/hi/{name}")
    public Screen hi(String name) {
        Tag msg = GUI.h4("Hi, ", GUI.i(name), "!");
        return GUI.page(msg).brand("What is your name?");
    }
 
}
GET /hi/Rapidoid

Hi, Rapidoid!

POST /hi/there

Hi, there!

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET POST /hi/{name} main html hi/name
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
Simple.java
@Controller
public class Simple {
 
    @Page
    public Object simple() {
        return "<p><b>RAW</b> HTML!<p>";
    }
 
}
GET /simple

RAW HTML!

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET POST /simple main html simple
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
Movie.java
public class Movie {
    public String title;
    public int year;
}
Movies.java
@Controller
public class Movies {
 
    @Page("/")
    public Object movie() {
        Movie movie = new Movie();
        movie.title = "Chappie";
        movie.year = 2015;
 
        Form form = GUI.show(movie).buttons(GUI.btn("OK"));
        return GUI.page(form).brand("Movie details");
    }
 
}
GET /
Chappie
2015

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET POST / main html index
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
Movie.java
public class Movie {
    public String title;
    public int year;
}
Movies.java
@Controller
public class Movies {
 
    @Page("/")
    public Object movie() {
        Movie movie = new Movie();
        movie.title = "Chappie";
        movie.year = 2015;
 
        Btn save = GUI.btn("Save").primary();
        Form form = GUI.edit(movie).buttons(save);
        return GUI.page(form).brand("Edit movie details");
    }
 
}
GET /

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET POST / main html index
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
ParamGrid.java
@Controller
public class ParamGrid {
 
    @Page
    public Object table(Req req) {
        return GUI.page(GUI.grid(req.params())).brand("Request parameters");
    }
 
}
GET /table?name=Rambo&age=50&weapon=gun
Key Value
name Rambo
age 50
weapon gun

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET POST /table main html table
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
Bar.java
import org.rapidoid.annotation.Controller;
import org.rapidoid.annotation.GET;
 
import javax.inject.Inject;
 
@Controller("/bar")
public class Bar {
 
    @Inject
    public Foo foo;
 
    @GET("/hi")
    public String hello() {
        return foo.msg();
    }
 
    public String msg() {
        return "Hello from Bar!";
    }
 
}
Foo.java
import org.rapidoid.annotation.Controller;
import org.rapidoid.annotation.GET;
 
import javax.inject.Inject;
 
@Controller("/foo")
public class Foo {
 
    @Inject
    public Bar bar;
 
    private int count;
 
    @GET("/hi")
    public String hello() {
        return ++count + ": " + bar.msg();
    }
 
    public String msg() {
        return "Hello from Foo!";
    }
 
}
GET /foo/hi
"1: Hello from Bar!"
GET /bar/hi
"Hello from Foo!"
GET /foo/hi
"2: Hello from Bar!"

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /bar/hi main json
GET /foo/hi main json
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
BootstrapLayout.java
@Controller
public class BootstrapLayout extends GUI {
 
    @Page("/")
    public Object layout() {
        Tag r1 = row(col4("A"), col4("B"), col4("C"));
        Tag r2 = row(col1("2/12"), col7("7/12"), col4("3/12"));
        Tag r3 = mid4("4/12 in the middle");
        return multi(r1, r2, r3);
    }
 
}
GET /
A
B
C
2/12
7/12
3/12
4/12 in the middle

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET POST / main html index
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
Highlighting.java
@Controller
public class Highlighting extends GUI {
 
    @Page("/")
    public Object letters() {
        return highlight("ab-cd-efg", "\\\\w+");
    }
 
}
GET /
ab-cd-efg

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET POST / main html index
Name Desc Default value
config configuration filename prefix config
dev run in DEV mode auto-detected
production run in PRODUCTION mode auto-detected
test run in TEST mode auto-detected
secret=<SECRET> configure secret key for cryptography random
profiles=<P1,P2...> comma-separated list of application profiles (e.g. mysql,prod) the 'default' profile
on.port=<P> the default App server will listen at port P 8888
on.address=<ADDR> the default App server will listen at address ADDR 0.0.0.0
admin.port=<P> the Admin server will listen at port P same as on.port
admin.address=<ADDR> the Admin server will listen at address ADDR on.address
app.services=<S1,S2...> comma-separated list of services to bootstrap on the App server none
admin.services=<S1,S2...> comma-separated list of services to bootstrap on the Admin server none