Home
Softono

Kindling

Open source Apache-2.0 Java
18
Stars
0
Forks
0
Issues
2
Watchers
1 year
Last Commit

 About Kindling

The fuel that'll ignite your application. A programmable TLS HTTP/1.1 server with no dependencies.

Platforms

Web Self-hosted Cloud Kubernetes

Languages

Java Go

Need Help Installing Kindling?

We provide expert installation service for this software. Our team will install, configure, and secure Kindling on your server. plans start at just $30.

Kindling

The fuel that'll ignite your application.

A programmable TLS HTTP/1.1 server written with no dependencies.

Key Features

  • SSL/TLS only (using SSLServerSocket)
  • No magic with visible control flow
  • Light weight
  • No Dependencies
  • Virtual Threads

Example

Below is an example implementation of a Kindling Server with a simple request handler that responds with a JSON object to a GET request on the / resource.

public class Main {
    public static void main(String[] args) throws KindlingException {

        KindlingServer server = KindlingServer.getInstance();

        // test request handler
        server.installRequestHandler(new RequestHandler() {
            /**
             * Tell the server what type of request this handler can work with
             */
            @Override
            public boolean accepts(HttpRequest httpRequest) throws KindlingException {
                return httpRequest.getHttpMethod().equals(HttpMethod.GET) && httpRequest.getResource().equals("/");
            }

            /**
             * Do your business logic here
             */
            @Override
            public HttpResponse handle(HttpRequest httpRequest) throws KindlingException {
                return new HttpResponse.Builder()
                        .status(HttpStatus.OK)
                        .contentType(MimeType.APPLICATION_JSON)
                        .content("{\"key\": \"value\"}")
                        .build();
            }
        });

        // serve our server
        server.serve(8443, Path.of("keystore.p12"), "password");
    }
}

Let's break down the components above.

  • KindlingServer
    • The singleton that contains the application context
    • Manages the SSLServerSocket and the virtual thread that is assigned to each request
  • RequestHandler
    • Accepts
      • Called when a request is received
      • Return a boolean telling the server if we can handle this request
    • Handle
      • If the accepts() method returns true, handle() is called
      • Do your business logic here, returning an HttpResponse
  • Server Serve
    • Start serving the SSLServerSocket on the provided port with the given P12 keystore