When you need the fewest moving parts
The simplest Minum program (see more code samples below):
public class Main {
public static void main(String[] args) {
var minum = FullSystem.initialize();
var wf = minum.getWebFramework();
wf.registerPath(GET, "",
r -> Response.htmlOk("<p>Hi there world!</p>"));
minum.block();
}
}There is a 🚀 Quick start, or if you have a bit more time, consider trying the tutorial
<dependency>
<groupId>com.renomad</groupId>
<artifactId>minum</artifactId>
<version>3.0.0</version>
</dependency>- Secure TLS 1.3 HTTP/1.1 web server
- In-memory database with disk persistence
- Server-side templating
- Logging framework
- Testing framework
- HTML parsing
Compiled size: 150 kilobytes.
Lines of production code (including required dependencies)
| Minum | Javalin | Spring Boot |
|---|---|---|
| 4,396 | 141,048 | 1,085,405 |
See details
- 19,000 http responses per second by web server. detail
- 2,000,000 updates per second to database. detail
- 27,000 templates per second rendered. detail
See framework performance comparison
See the following links for sample projects that use this framework.
This project is valuable to see the minimal-possible application that can be made. This might be a good starting point for use of Minum on a new project.
This is a good example to see a basic project with various functionality. It shows many of the typical use cases of the Minum framework.
This is a family-tree project. It demonstrates the kind of approach this framework is meant to foster.
Instantiating a new database:
var db = new Db<>(foosDirectory, context, new Foo());Adding a new object to a database:
var foo = new Foo(0L, 42, "blue");
db.write(foo); Updating an object in a database:
foo.setColor("orange");
db.write(foo); Deleting from a database:
db.delete(foo); Writing a log statement:
logger.logDebug(() -> "hello");Parsing an HTML document:
List<HtmlParseNode> results = new HtmlParser().parse("<p></p>");Searching for an element in the parsed graph:
HtmlParseNode node;
List<HtmlParseNode> results = node.search(TagName.P, Map.of());Creating a new web handler (a function that handles an HTTP request and returns a response):
public Response myHandler(Request r) {
return Response.htmlOk("<p>Hi world!</p>");
}Registering that endpoint:
webFramework.registerPath(GET, "formentry", sd::formEntry);Building and rendering a template:
TemplateProcessor foo = TemplateProcessor.buildProcessor("hello {{ name }}");
String rendered = foo.renderTemplate(Map.of("name", "world"));Getting a query parameter from a request:
String id = r.requestLine().queryString().get("id");Getting a body parameter from a request, as a string:
String personId = request.body().asString("person_id");Getting a body parameter from a request, as a byte array:
byte[] photoBytes = body.asBytes("image_uploads");