rabbah commented on a change in pull request #2218: Port Controller from Spray to Akka URL: https://github.com/apache/incubator-openwhisk/pull/2218#discussion_r132818376
########## File path: common/scala/src/main/scala/whisk/http/BasicHttpService.scala ########## @@ -137,29 +145,19 @@ trait BasicHttpService extends HttpService with TransactionCounter { Some(LogEntry(s"[$tid] [$name] $marker", l)) case _ => None // other kind of responses } + + val bindingFuture = { + Http().bindAndHandle(route, "0.0.0.0", port) + } + + def shutdown(): Future[Unit] = { + bindingFuture.flatMap(_.unbind()).map(_ => ()) + } } object BasicHttpService extends Directives { - def startService[T <: Actor](system: ActorSystem, name: String, interface: String, port: Integer, service: Creator[T]) = { + def startService[T <: Actor](system: ActorSystem, name: String, interface: String, service: Creator[T]) = { val actor = system.actorOf(Props.create(service), s"$name-service") - implicit val timeout = Timeout(5 seconds) - IO(Http)(system) ? Http.Bind(actor, interface, port) - } - - /** Rejection handler to terminate connection on a bad request. Delegates to Spray handler. */ - def customRejectionHandler(implicit transid: TransactionId) = RejectionHandler { - // get default rejection message, package it as an ErrorResponse instance - // which gets serialized into a Json object - case r if RejectionHandler.Default.isDefinedAt(r) => { - ctx => - RejectionHandler.Default(r) { - ctx.withHttpResponseMapped { - case resp @ HttpResponse(_, HttpEntity.NonEmpty(ContentType(`text/plain`, _), msg), _, _) => - resp.withEntity(marshalling.marshalUnsafe(ErrorResponse(msg.asString, transid))) - } - } - } - case CustomRejection(status, cause) :: _ => complete(status, ErrorResponse(cause, transid)) Review comment: this in particular was used for the auth failure mode https://github.com/apache/incubator-openwhisk/issues/2607. we can delete CustomRejection since it will be unused now - assuming we keep this behavior. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services