compose is a functional web application framework written in Scala. The aim is to eventually provide a full-featured backend web stack that encourages building applications through defining and composing small functions.
Did the world need another web framework? No, not really.
I started work on this because I was interested in seeing how far I could go in building a web frameowrk based on three principles:
- A web application is just a function of type
Request => Response
- A web server is just a function of type
Application => Nothing(i.e., a function that takes an application and does not return)
- Middleware is any kind of function that composes to modify the behavior of a web application (e.g., compressing response bodies or authenticating requests), or to produce one from a combination of others (e.g., routing).
At the moment, compose is extremely incomplete. There's a development server that can respond to requests, but no attempt has been made to ensure that it's correct or reliable enough for production use. It's definitely not ready for production, and it may never be.
First, ensure that you have:
- a jdk compatible with at least Java 9 (compose makes use of some IO methods not present in jdk8)
- Scala 2.13
- sbt 1.3
Then you can start the demo application with:
sbt 'runMain compose.demos.GreetingsDemo'
From another terminal, you can hit the demo server:
curl -v 'http://127.0.0.1:8080/greet/World'
The bulk of the code and tests lives in the
core project directory. Example applications live in
demos. You can use all of the normal sbt commands to compile (
sbt compile), run tests (
sbt test), or open a scala repl with everything loaded (
The basic types (
types.scala) and the
Response classes should be good entry points to understanding how everything fits together. Full api documentation for the latest release can be found on javadoc.io, and docs for your current working copy can be generated by running
sbt doc and checking out
Feature work should branch off
main, and branch names should not begin with
release. Branches preparing releases will be named
release/$VERSION and will be merged into
releases and tagged accordingly.
© 2020 David Hollis