org.microhttp/microhttp
org.microhttp
ebarlas/microhttp
Microhttp is an implementation of an HTTP/1.1 server.
This means that it can handle things like GET
and POST
requests, but not securing a connection with SSL or websocket connections.
It is very fast and, as a result of eschewing support for most convenience features and other protocols, it has a codebase that can be reasonably read and understood fully in a day or two at most.
It discretizes requests and responses, which is a problem if you were expecting to handle file uploads or other such tasks directly, but a non-issue if you only intend to send and receive payloads of reasonable size.
In order to publish to the wider internet, you will need to have SSL. That Microhttp doesn't handle this natively isn't that much of an issue since most platforms as a service like Heroku, Railway, and Render provide this by default. As will any load balancer or properly configured nginix
.
import org.microhttp.EventLoop;
import org.microhttp.Response;
import org.microhttp.Header;
void main() throws Exception {
= new EventLoop((request, callback) -> {
var eventLoop .accept(new Response(
callback200,
"OK",
List.of(new Header("Content-Type", "text/plain")),
"Hello, world".getBytes()
));
});
.start();
eventLoop.join();
eventLoop}