diff options
author | Jakob Odersky <jakob@odersky.com> | 2017-03-18 01:58:01 -0400 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2017-03-18 01:58:01 -0400 |
commit | dff97b40df39e5eb391e1fc30ca47180384f1747 (patch) | |
tree | 76d1a4d3af4c8a0b8b316a151d40493e8f22957b /crashbox-server/src/main/scala/io/crashbox/ci/HttpApi.scala | |
parent | 3f00b87a022e92e3bf341d40d05d81b5538e4974 (diff) | |
download | crashbox-ci-dff97b40df39e5eb391e1fc30ca47180384f1747.tar.gz crashbox-ci-dff97b40df39e5eb391e1fc30ca47180384f1747.tar.bz2 crashbox-ci-dff97b40df39e5eb391e1fc30ca47180384f1747.zip |
Refactor trait-based dependencies to constructor parametersnocake
Diffstat (limited to 'crashbox-server/src/main/scala/io/crashbox/ci/HttpApi.scala')
-rw-r--r-- | crashbox-server/src/main/scala/io/crashbox/ci/HttpApi.scala | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crashbox-server/src/main/scala/io/crashbox/ci/HttpApi.scala b/crashbox-server/src/main/scala/io/crashbox/ci/HttpApi.scala index c9e62c3..cbdbbf1 100644 --- a/crashbox-server/src/main/scala/io/crashbox/ci/HttpApi.scala +++ b/crashbox-server/src/main/scala/io/crashbox/ci/HttpApi.scala @@ -14,7 +14,8 @@ import akka.stream.scaladsl.{Source => Src} import akka.stream.scaladsl.StreamConverters import spray.json._ -trait HttpApi { self: Core with Schedulers with Storage => +class HttpApi(scheduler: Scheduler, storage: Storage)(implicit core: Core) { + import core._ val endpoint = "api" @@ -46,21 +47,21 @@ trait HttpApi { self: Core with Schedulers with Storage => path("submit") { post { entity(as[Request]) { req => - val scheduled = scheduleBuild(req.url).map(_.toString()) + val scheduled = scheduler.scheduleBuild(req.url).map(_.toString()) complete(scheduled) } } } ~ path(Segment / "cancel") { buildId => post { - cancelBuild(UUID.fromString(buildId)) + scheduler.cancelBuild(UUID.fromString(buildId)) complete(204 -> None) } } ~ path(Segment / "logs") { buildId => get { val src = StreamConverters - .fromInputStream(() => readLog(UUID.fromString(buildId), 0)) + .fromInputStream(() => storage.readLog(UUID.fromString(buildId), 0)) .map { bs => bs.utf8String } |