dubeejw commented on a change in pull request #2218: Port Controller from Spray
to Akka
URL:
https://github.com/apache/incubator-openwhisk/pull/2218#discussion_r130398004
##########
File path: common/scala/src/main/scala/whisk/http/BasicHttpService.scala
##########
@@ -86,39 +94,58 @@ trait BasicHttpService extends HttpService with
TransactionCounter {
*/
def loglevelForRoute(route: String): Logging.LogLevel = Logging.InfoLevel
+ /** Rejection handler to terminate connection on a bad request. Delegates
to Akka handler. */
+ val prioritizeRejections = recoverRejections { rejections =>
+ val priorityRejection =
rejections.find(_.isInstanceOf[UnacceptedResponseContentTypeRejection]).getOrElse(null)
+
+ if (priorityRejection != null) {
+ Rejected(Seq(priorityRejection))
+ } else {
+ Rejected(rejections)
+ }
+ }
+
+ val toStrict = mapInnerRoute { innerRoute =>
+ extractRequest { req =>
+ onSuccess(req.toStrict(1.second)) { strictReq =>
+ mapRequest(_ => strictReq) {
+ innerRoute
+ }
+ }
+ }
+ }
+
/**
* Receives a message and runs the router.
*/
- def receive = runRoute(
+ def route: Route = {
assignId { implicit transid =>
- DebuggingDirectives.logRequest(logRequestInfo _) {
- DebuggingDirectives.logRequestResponse(logResponseInfo _) {
- routes
+ handleRejections(customRejectionHandler) {
+ prioritizeRejections {
+ DebuggingDirectives.logRequest(logRequestInfo _) {
+ DebuggingDirectives.logRequestResult(logResponseInfo
_) {
+ toStrict {
+ routes
+ }
+ }
+ }
}
}
- })
+ }
+ }
+
+ def receive = {
+ case _ =>
+ }
Review comment:
```
open/common/scala/src/main/scala/whisk/http/BasicHttpService.scala:58:
implicit ActorRefFactory required: if outside of an Actor you need an implicit
ActorSystem, inside of an actor this should be the implicit ActorContext
implicit val materializer = ActorMaterializer()
^
open/common/scala/src/main/scala/whisk/http/BasicHttpService.scala:59: not
found: value context
implicit val actorSystem = context.system
```
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services