diff options
Diffstat (limited to 'mavigator-server/src/main/scala/mavigator/Router.scala')
-rw-r--r-- | mavigator-server/src/main/scala/mavigator/Router.scala | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/mavigator-server/src/main/scala/mavigator/Router.scala b/mavigator-server/src/main/scala/mavigator/Router.scala index b74e3a6..561b096 100644 --- a/mavigator-server/src/main/scala/mavigator/Router.scala +++ b/mavigator-server/src/main/scala/mavigator/Router.scala @@ -10,15 +10,34 @@ import akka.http.scaladsl.server._ import uav.Uav import akka.util._ +import akka.http.scaladsl.marshalling.{Marshaller, ToEntityMarshaller} +import akka.http.scaladsl.model.MediaTypes._ +import akka.http.scaladsl.model.MediaType +import play.twirl.api.{ Xml, Txt, Html } + + object Router { + /** Serialize Twirl `Html` to `text/html`. */ + implicit val twirlHtmlMarshaller = twirlMarshaller[Html](`text/html`) + + /** Serialize Twirl formats to `String`. */ + def twirlMarshaller[A <: AnyRef: Manifest](contentType: MediaType): ToEntityMarshaller[A] = + Marshaller.StringMarshaller.wrap(contentType)(_.toString) + + import Directives._ def route(implicit system: ActorSystem): Route = ( path("info") { get { - val f: play.twirl.api.Html = mavigator.views.html.index() - complete(f.body) + val f: Html = mavigator.views.html.dashboard( + "socket", + 0, + 0, + 0 + ) + complete(f) } } ~ path("dashboard" / IntNumber) { id => |