diff options
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 | 39 |
1 files changed, 23 insertions, 16 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 7cb76b0..71a4f5b 100644 --- a/crashbox-server/src/main/scala/io/crashbox/ci/HttpApi.scala +++ b/crashbox-server/src/main/scala/io/crashbox/ci/HttpApi.scala @@ -32,7 +32,7 @@ trait HttpApi { self: Core with Schedulers with StreamStore => } import Protocol._ - implicit val toResponseMarshaller: ToResponseMarshaller[Src[BuildState, Any]] = + implicit val toResponseMarshaller: ToResponseMarshaller[Src[String, Any]] = Marshaller.opaque { items => val data = items.map(item => ChunkStreamPart(item.toString + "\n")) HttpResponse( @@ -41,22 +41,29 @@ trait HttpApi { self: Core with Schedulers with StreamStore => def httpApi: Route = pathPrefix(endpoint) { path("submit") { - entity(as[Request]) { req => - val source = Src - .queue[BuildState](100, OverflowStrategy.fail) - .mapMaterializedValue { q => - start( - req.buildId, - new URL(req.url), - () => saveStream(req.buildId), - state => q.offer(state) - ) - } - - complete(source) + post { + entity(as[Request]) { req => + val source = Src + .queue[String](100, OverflowStrategy.fail) + .mapMaterializedValue { q => + q.offer(s"Build ID: ${req.buildId}") + start( + req.buildId, + new URL(req.url), + () => saveStream(req.buildId), + state => q.offer(state.toString) + ) + } + complete(source) + } + } + } ~ + path(Segment / "cancel") { buildId => + post { + cancel(buildId) + complete(204 -> s"Cancelled $buildId") + } } - - } } } |