A modern, cutting-edge Java web framework designed for high-performance and scalability.
- High Performance: Built with performance in mind, optimized for speed and efficiency.
- Scalability: Designed to handle large loads with ease, ensuring reliability and availability.
- Modern Architecture: Leveraging the latest Java technologies and best practices for robustness and maintainability.
To see a complete Cirrus application in action, check out the Cirrus Demo.
Use the sensibleDefaults() modifier to enable all recomended default modifiers or extensions.
public static void run(final String[] args) {
new Cirrus()
.port(9595)
.sensibleDefaults()
.routes(new App())
.run();
}Want a feature? Simply add it, for example, Logging
public static void run(final String[] args) {
new Cirrus()
.port(9595)
.logging()
.routeAdapters(new App())
.run();
}Can't find what you're looking for? No problem, make it!
public final class MyExtension implements CirrusExtension {
@Override
public void apply(final CirrusContext context) {
// do stuff!
}
}
/*
* Usage:
* new Cirrus()
* .modify(new MyExtension())
* .run();
*/Note
These will be executed in the order they are added. If logging is added after routeAdapters, the router will not be able to log requests.
@Get("/api/users")
public Object apiUsers(final RequestContext req, final ResponseContext res) {
return res.json(users);
}Here are some of the features demonstrated in the demo:
@Post("/users/<id>/delete")
public Object deleteUser(final RequestContext req, final ResponseContext res) {
final int id = Integer.parseInt(req.param("id"));
users.removeIf(u -> u.id() == id);
return res.redirect("/users");
}@Get("/")
public String index(final RequestContext req, final ResponseContext res) {
final List<String> features = List.of(
"Annotation-based routing (@Get, @Post, etc.)",
"Path parameters: /users/<id>",
"Query parameters: ?name=value",
"Form handling",
"Clean, modern templating",
"Template inheritance",
"Built on Netty"
);
return Cirrus.render("index.html", Map.of(
"message", "Hello from Cirrus!",
"features", features
));
}And the templates:
base.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}Cirrus{% endblock %}</title>
<style>
body {
font-family: system-ui, sans-serif;
max-width: 800px;
margin: 50px auto;
padding: 20px;
}
h1 {
color: #333;
}
form {
margin: 20px 0;
}
input, button {
padding: 10px;
margin: 5px 0;
}
input[type="text"] {
width: 300px;
}
button {
background: #0066cc;
color: white;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>index.html:
{% extends "base.html" %}
{% block title %}Welcome to Cirrus{% endblock %}
{% block content %}
{% if message %}
<p><strong>{{ message }}</strong></p>
{% endif %}
<h2>Features</h2>
<ul>
{% for feature in features %}
<li>{{ feature }}</li>
{% endfor %}
</ul>
{% endblock %}Simply add the repo and the libraries to your pom.xml file!
<properties>
<!-- ... -->
<cirrus-version>{version (see https://github.com/CirklAI/cirrus/releases)}</cirrus-version>
</properties>
<repositories>
<repository>
<id>cirkl-releases</id>
<name>Cirkl Releases</name>
<url>https://maven.cirkl.ai/releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>ai.cirkl.oss</groupId>
<artifactId>cirrus-api</artifactId>
<version>${cirrus-version}</version>
</dependency>
<dependency>
<groupId>ai.cirkl.oss</groupId>
<artifactId>cirrus-core</artifactId>
<version>${cirrus-version}</version>
</dependency>
</dependencies>