jvm/src/sqwl/cms/Server.scala
changeset 4 1a1347e8c5be
parent 3 48479e4b89d4
child 5 de7c56ce0654
equal deleted inserted replaced
3:48479e4b89d4 4:1a1347e8c5be
     1 package sqwl.cms
       
     2 
       
     3 import akka.actor.ActorSystem
       
     4 import akka.http.scaladsl.Http
       
     5 import akka.http.scaladsl.model.{ContentTypes, HttpEntity}
       
     6 import akka.http.scaladsl.server.Directives._
       
     7 import akka.stream.{ActorMaterializer, Materializer}
       
     8 
       
     9 import scala.concurrent.ExecutionContextExecutor
       
    10 
       
    11 object Server extends App with Service with config with UrlScheme {
       
    12   override implicit val system: ActorSystem = ActorSystem()
       
    13   override implicit val executor: ExecutionContextExecutor = system.dispatcher
       
    14   override implicit val materializer: Materializer = ActorMaterializer()
       
    15 
       
    16   private val routes = get {
       
    17     path(http.prefix) {
       
    18       complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "main"))
       
    19     } ~ pathPrefix(http.prefix / ASSETS) {
       
    20       getFromResourceDirectory("META-INF/resources/webjars")
       
    21     } ~ pathPrefix(http.prefix / PUBLIC) {
       
    22       getFromResourceDirectory("public")
       
    23     }
       
    24   }
       
    25 
       
    26   Http().bindAndHandle(routes, http.interface, http.port)
       
    27 
       
    28 }