Git Product home page Git Product logo

espresso's Introduction

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

espresso's People

Contributors

sunng87 avatar

Stargazers

 avatar 吴上阿吉 avatar GAURAV avatar  avatar davylin avatar Ioan Rîpan avatar Tom Haines avatar Rui Guo avatar Daniel Kirsch avatar Michael Wong avatar Hasnat Babur avatar Sergey Rublev avatar Thierry Uriot avatar Chris Zheng avatar  avatar Trevor Gowing avatar  avatar Bohdan avatar Ivo Limmen avatar forseti avatar W. avatar Jan Keim avatar

Watchers

 avatar Oscar Trigueiros avatar James Cloos avatar rad avatar

Forkers

icodein

espresso's Issues

Content negotiation library

As we already have Sugar to decode request parameters, we will need its par for Http Response, that encode http response into particular format based on accept header of request, for example, application/json

It has to be as extensible as Sugar. User will be able to plugin their own encoder for particular MIME, for example, even a qrcode can be generated in this way.

Cookie library

Without servlet API, we will need a middleware to extract cookie from http header Set-Cookie and provide a data structure for user to consume cookies.

The API could be like:

Cookie cookie = Cookie.extension(request).get("somecookie")

Using bifurcan for internal data structure

https://github.com/lacuna/bifurcan Bifurcan is a super fast persistent data structure library from Zach Tellman. In espresso, middlewares will exchange data in the extension map of request and response frequently. So we would like to switch to persistent data structure to speed up extension manipulation, for the functional programming scenario with espresso.

UnderTow adapter

Currently the Jettino adapter is based on Jetty and Servlet API, which has additional overhead when copy servelt request to espresso.

UnderTow provides a non-servlet api and we can see if it will work with espresso.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.