You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/06/13 18:26:49 UTC

[GitHub] markusthoemmes commented on a change in pull request #3661: Restrict allowed namespaces when creating action of certain kinds

markusthoemmes commented on a change in pull request #3661: Restrict allowed namespaces when creating action of certain kinds
URL: https://github.com/apache/incubator-openwhisk/pull/3661#discussion_r195189406
 
 

 ##########
 File path: core/controller/src/main/scala/whisk/core/controller/Actions.scala
 ##########
 @@ -119,15 +119,22 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with
   protected override def innerRoutes(user: Identity, ns: EntityPath)(implicit transid: TransactionId) = {
     (entityPrefix & entityOps & requestMethod) { (segment, m) =>
       entityname(segment) { outername =>
-        pathEnd {
+        (pathEnd & put & entity(as[WhiskActionPut])) { (content) =>
+          val request = content.resolve(user.namespace)
+          val resourceData = request.exec match {
+            case Some(e) => Some(ResourceData(e))
+            case None    => None
+          }
 
 Review comment:
   Throughout your code you can replace many if not all the occurences of pattern-matching on `Option` with methods on Option. `map` is only executed on `Some` and will pass `None` on for instance so this code is equal to:
   
   ```scala
   val resourceData = request.exec.map(e => ResourceData(e))
   ```
   
   I'll comment on some more occurences to show some more combinators.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services