jvm/src/sqwl/cms/Server.scala
author Tomas Zeman <tzeman@volny.cz>
Thu, 22 Nov 2018 13:15:29 +0100
changeset 3 48479e4b89d4
permissions -rw-r--r--
App skeleton

package sqwl.cms

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{ContentTypes, HttpEntity}
import akka.http.scaladsl.server.Directives._
import akka.stream.{ActorMaterializer, Materializer}

import scala.concurrent.ExecutionContextExecutor

object Server extends App with Service with config with UrlScheme {
  override implicit val system: ActorSystem = ActorSystem()
  override implicit val executor: ExecutionContextExecutor = system.dispatcher
  override implicit val materializer: Materializer = ActorMaterializer()

  private val routes = get {
    path(http.prefix) {
      complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "main"))
    } ~ pathPrefix(http.prefix / ASSETS) {
      getFromResourceDirectory("META-INF/resources/webjars")
    } ~ pathPrefix(http.prefix / PUBLIC) {
      getFromResourceDirectory("public")
    }
  }

  Http().bindAndHandle(routes, http.interface, http.port)

}