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)
}