@capotej website

Announcing Finatra 1.0.0

After months of work Finatra 1.0.0 is finally available! Finatra is a scala web framework inspired by Sinatra built on top of Finagle.

The API

The API looks like what you’d expect, here’s a simple endpoint that uses route parameters:

get("/user/:username") { request =>
  val username = request.routeParams.getOrElse("username", "default_user")
  render.plain("hello " + username).toFuture
}

The toFuture call means that the response is actually a Future, a powerful concurrency abstraction worth checking out.

Testing it is just as easy:

"GET /user/foo" should "responsd with hello foo" in {
  get("/user/foo")
  response.body should equal ("hello foo")
}

A super quick demo

$ git clone https://github.com/capotej/finatra.git
$ cd finatra
$ ./finatra new com.example.myapp /tmp

Now you have an /tmp/myapp you can use:


$ cd /tmp/myapp
$ mvn scala:run

A simple app should’ve started up locally on port 7070, verify with:

$ curl http://locahost:7070
hello world

You can see the rest of the endpoints at /tmp/myapp/src/main/scala/com/example/myapp/App.scala

Heroku integration

The generated apps work in heroku out of the box:

$ heroku create
$ git init
$ git add .
$ git commit -am 'stuff'
$ git push heroku master

Make sure to see the full details in the README and check out the example app.

Props to @twoism and @thisisfranklin for their code, feedback and moral support.

#finatra #scala