markusthoemmes commented on a change in pull request #2577: Support multiple 
response header values in raw web actions
URL: 
https://github.com/apache/incubator-openwhisk/pull/2577#discussion_r131519212
 
 

 ##########
 File path: 
core/controller/src/main/scala/whisk/core/controller/WebActions.scala
 ##########
 @@ -251,6 +248,14 @@ protected[core] object WhiskWebActionsApi extends 
Directives {
         }
     }
 
+    private def headersFromJson(k: String, v: JsValue) : Seq[RawHeader] = v 
match {
+        case JsString(v)  => Seq(RawHeader(k, v))
+        case JsBoolean(v) => Seq(RawHeader(k, v.toString))
+        case JsNumber(v)  => Seq(RawHeader(k, v.toString))
+        case JsArray(v)   => v.map(headersFromJson(k, _:JsValue)).flatten
 
 Review comment:
   Same comment on `flatMap`. In general, nesting a `_` can become tricky. I'd 
prefer fat-arrow notation in this case, the non inferred type seems confusing.
   
   ```scala
   case JsArray(v)   => v.flatMap(inner => headersFromJson(k, inner))
   ```
 
----------------------------------------------------------------
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

Reply via email to