/espresso

The Soul of Modern Java Web Application

Primary LanguageJavaApache License 2.0Apache-2.0

Espresso

Maven Central Javadocs Travis (.org) GitHub Mailing-list Liberapay patrons

Web application from a function. The soul of modern Java web application.

image

Original Image

Rationale

Java is getting modern and the web ecosystem needs evolution, too. The idea of Espresso is inspired from Ring (Clojure), Iron (Rust) and WSGI (Python). Espresso defined a protocol between web application/framework and web server. It tries to replace Servlet API, which is heavy, verbose, complex and not friendly for unit-test.

Key concepts of espresso ecosystem:

  • App: Espresso function implementation.
  • Server: A container to run espresso function.
  • Adapter: A adapter layer for existed Java web server to run espresso function.
  • Plugin or Middleware: An espresso function wrapper that provides additional features or data to core espresso function.

Usage

The core of Espresso is an Java interface Espresso, which has only one method that takes a Request as input, and returns a Response.

With Java's functional interface feature, the implementation can be as short as a lambda.

import io.github.espresso4j.espresso.*;

// ...

var app = (req) -> Response.of(200).body("<h1>It works</h1>");

The web app will always return a page says It works.

Espresso also provides an async variance called Espresso.Async if your application is fully asynchronous:

import io.github.espresso4j.espresso.*;

// ...

var app = (req, sender, raiser) ->
        sender.accept(Response.of(200).body("<h1>It works</h1>"));

Espresso Echosystem

  • Jettino An espresso adapter for Jetty
  • Latte url router for Espresso
  • Sugar parameter extractor

Joining the community

Joining our mailing-list.

License

See license