diff options
author | Li Haoyi <haoyi@dropbox.com> | 2014-02-24 01:28:51 -0800 |
---|---|---|
committer | Li Haoyi <haoyi@dropbox.com> | 2014-02-24 01:28:51 -0800 |
commit | 31438faf71f42f11fe220fa8295dfc33d49ea808 (patch) | |
tree | e3e6b310fbf3999e3fd85e0d1b039757f187d0c7 | |
parent | dc074512f5f3faf140beca2b42713c1100cafb28 (diff) | |
download | workbench-31438faf71f42f11fe220fa8295dfc33d49ea808.tar.gz workbench-31438faf71f42f11fe220fa8295dfc33d49ea808.tar.bz2 workbench-31438faf71f42f11fe220fa8295dfc33d49ea808.zip |
tweak
-rw-r--r-- | Plugin.scala | 18 | ||||
-rw-r--r-- | build.sbt | 2 |
2 files changed, 15 insertions, 5 deletions
diff --git a/Plugin.scala b/Plugin.scala index 8f09c11..725f265 100644 --- a/Plugin.scala +++ b/Plugin.scala @@ -16,9 +16,12 @@ import Keys._ import com.typesafe.config.ConfigFactory import scala.collection.mutable import akka.io.Tcp -import spray.http.{StatusCodes, HttpResponse, HttpRequest} -import spray.http.HttpHeaders.Connection +import spray.http._ +import spray.http.HttpHeaders.{`Access-Control-Allow-Origin`, Connection} import spray.can.server.websockets.model.OpCode.Text +import spray.http.HttpRequest +import play.api.libs.json.JsArray +import spray.http.HttpResponse object Plugin extends sbt.Plugin { val refreshBrowsers = taskKey[Unit]("Sends a message to all connected web pages asking them to refresh the page") @@ -108,10 +111,17 @@ object Plugin extends sbt.Plugin { if (req.headers.contains(Connection("Upgrade"))){ sender ! Sockets.UpgradeServer(Sockets.acceptAllFunction(req), self) }else{ - req. + + import java.nio.file.{Files, Paths} + + val data = Files.readAllBytes(Paths.get(req.uri.path.toString())) + sender ! HttpResponse( StatusCodes.OK, - entity="i am a cow" + entity=HttpEntity.apply(MediaTypes.`text/html`, data), + headers=List( + `Access-Control-Allow-Origin`(spray.http.AllOrigins) + ) ) } @@ -1,6 +1,6 @@ import sbt.Keys._ -lazy val root = project.dependsOn(uri("git://github.com/lihaoyi/SprayWebSockets.git")) +lazy val root = project.in(file(".")).dependsOn(uri("git://github.com/lihaoyi/SprayWebSockets.git")) name := "scala-js-workbench" |