Contents

Bootzooka is now based on Akka HTTP

Times change, and so does Bootzooka, our simple application scaffolding project: the backend is now based on Akka HTTP.

Akka HTTP (formerly known as Spray.io) is a HTTP client & server implementation on top of Akka & Akka Stream, with a very flexible and elegant routing DSL for defining endpoints. It's not a web framework, it's not an application server; instead, you get a library, on top of which you can implement various services.

So isn't it a lot of work to create a web application using Akka HTTP? Turns out it's quite simple. The biggest missing piece is session handling, which we released some time ago as a separate library, Akka HTTP Session. Apart from that, Akka HTTP has all that is needed for a Single Page Application: serving static files from a (resource) directory and defining HTTP/REST-endpoints.

I'm sure you'd like to see some code! For example, here's a route handling changing a user's password, taken from UserRoutes.scala:

case class ChangePasswordInput(currentPassword: String, newPassword: String)

path("changepassword") {
  post {
    userFromSession { user =>
      entity(as[ChangePasswordInput]) { input =>
        onSuccess(userService.changePassword(user.id, input)) {
          case Left(msg) => complete(StatusCodes.Forbidden, msg)
          case Right(_) => completeOk
        }
      }
    }
  }
}

All of the above are just function calls (post, path, etc.)! There's no reflection/annotation magic, or anything like that. The above route is also fully testable, in isolation, without the need to start up a server.

How can you run Bootzooka? You don't need any kind of container, embedded or not! All that you have to do is bind to a socket and pass in the routes which should handle incoming requests to an ActorSystem extension provided by Akka HTTP. Take a look yourself, from Main.scala:

Http().bindAndHandle(
  routes, 
  config.serverHost, 
  config.serverPort)

If you'd like to quickly start developing an application using Scala, Akka HTTP and Angular, Bootzooka is for you! Apart from what's described above, its has a lot of the "boring" features done, such as user registration, logging in/out, notifications, as well as an integrated SBT+Grunt build system, backend & frontend tests, fat-jar deployments (local and to Heroku).

In other words, all that you need when starting a new project to start coding business value, instead of infrastructure.

You can take a look at a live demo of the running application. Star the project on GitHub if you like it, and of course, if you would have any suggestions or contribution ideas, let us know!

Blog Comments powered by Disqus.