The goal of Akka Boot is to make it as easy as possible to create production ready HTTP services using Akka. Akka Boot takes care of the following items,
- Configuring Akka for ease of development while switching to robust production configuration using the -prod command line parameter.
- Configuring Akka HTTP to use HTTPS by default.
- Configuring Akka to disable Java serialization and use Kryo instead.
- Adding straightforward support for the actor per request model and ensuring that requests are handled on a separate dispatcher than the one used by Akka HTTP.
- Adding ScalaRouteBuilder to simplify route code and eliminate the need to know all the imports and implicits you need to make the routing DSL work.
- Adding HttpClient to provide a more traditional HTTP API to execute basic get, post and put requests.
- Configuring Akka to log requests and responses.
- Configuring Logback and route all logging frameworks to log through Logback.
- Configuring Jackson to simplify the use of Akka HTTPs marshalling functionality.
- Integrating Dropwizard metrics and making those metrics available via an HTTP endpoint.
- Integrating Dropwizard health checks and making those health checks available via an HTTP endpoint.
For complete documentation see the wiki.
Getting Started
- Add Akka Boot to your build.sbt file
libraryDependencies += "com.github.mfoody.akkaboot" %% "akka-boot-core" % "0.3"
- Create your first HTTP route
class GreeterRoute(system: ActorSystem, executionContext: ExecutionContext)
extends ScalaRouteBuilder(system, executionContext) {
override val route: Route = get {
pathPrefix("hellos") {
completeWithActor { // Handles actor per request
"Yo"
}
}
}
}
- Create an application and configuration class.
class HelloWorldConfiguration(config: Config) extends Configuration(config)
object HelloWorldApplication {
def main(args: Array[String]): Unit = {
new HelloWorldApplication(args).run()
}
}
class HelloWorldApplication(args: Array[String]) extends Application[HelloWorldConfiguration] {
override def run(configuration: HelloWorldConfiguration, environment: Environment): Environment = {
environment.route(new HelloWorldRoutes(environment.system, environment.apiDispatcher))
}
}
- Run your application
> sbt run
- Go to https://localhost