how to serve a html file correctly as correct content to a browser with akka-http?
<p>I am looking into the akka-http documentation, and find there how to serve html content with the low-level server api using HttpResponses. However, I can not find any good examples on how to serve html-content, which should be correctly represented in the browser. The only things that I find and can get working is when it serve String content as below. I found an example that:</p>

<pre><code>imports akka.http.scaladsl.marshallers.xml.ScalaXmlSupport._
</code></pre>

<p>but I can not see that scaladsl contains marshallers (it contains marshalling)   </p>

<pre><code>import akka.http.scaladsl.Http
import akka.stream.ActorMaterializer
import akka.http.scaladsl.server.Directives._
import akka.actor.ActorSystem

object HttpAkka extends App{

   implicit val system = ActorSystem()
   implicit val materializer = ActorMaterializer()
   implicit val ec = system.dispatcher

   val route = get {
       pathEndOrSingleSlash {
           complete("&lt;h1&gt;Hello&lt;/h1&gt;")
       }
   }

  Http().bindAndHandle(route, "localhost", 8080)

}
</code></pre>

<p>found a relevant question here <a href="https://stackoverflow.com/questions/32187858/akka-http-accept-and-content-type-handling?rq=1">Akka-http: Accept and Content-type handling</a></p>

<p>I did not fully understand the answer in that link, but tried the following (i eventually got this to work..):</p>

<pre><code>complete {
    HttpResponse(entity=HttpEntity(ContentTypes.`text/html(UTF-8)`, "&lt;h1&gt;Say Hello&lt;/h1&gt;"))
}
</code></pre>

<p>as well as:</p>

<pre><code>complete {
    respondWithHeader (RawHeader("Content-Type", "text/html(UFT-8"))
      "&lt;h1&gt; Say hello&lt;/h1&gt;"
    } 
</code></pre>