In this recipe, we will see how to create a minimal HTTP server using routing DSL. We will also make use of the HttpApp
trait, which provides a precooked server ready to be run.
To step through this recipe, we need to import the Hello-Akka
project; all the other prerequisites are the same as before. We need to get the required dependencies for http
this time.
For this recipe, perform the following steps:
- Get the required dependencies.
- Edit the
build.sbt
file and add the Akka HTTP dependency as follows:
libraryDependencies += "com.typesafe.akka" % "akka-http_2.11" % "10.0.5"
- Now create a file named
MinimalHttpServer.scala
. Define your server and a small object to run it:
package com.packt.chapter9 import akka.http.scaladsl.model.{ContentTypes, HttpEntity} import akka.http.scaladsl.server.HttpApp import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl...