jvm/src/sqwl/cms/Server.scala
changeset 3 48479e4b89d4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jvm/src/sqwl/cms/Server.scala	Thu Nov 22 13:15:29 2018 +0100
@@ -0,0 +1,28 @@
+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)
+
+}