ningyougang commented on code in PR #170:
URL:
https://github.com/apache/openwhisk-runtime-go/pull/170#discussion_r937253104
##########
common/gobuild.py.launcher.go:
##########
@@ -89,12 +91,29 @@ func main() {
}
}
// get payload if not empty
- var payload map[string]interface{}
+ isJsonObjectParam := true
+ var payloadForJsonObject map[string]interface{}
+ var payloadForJsonArray []interface{}
if value, ok := input["value"].(map[string]interface{}); ok {
- payload = value
+ payloadForJsonObject = value
+ } else {
+ if value, ok := input["value"].([]interface{}); ok {
+ payloadForJsonArray = value
+ isJsonObjectParam = false
+ }
}
// process the request
- result := action(payload)
+ var result interface{}
+ funcMain := reflect.ValueOf(Main)
+ if isJsonObjectParam {
+ param :=
[]reflect.Value{reflect.ValueOf(payloadForJsonObject)}
+ reflectResult := funcMain.Call(param)
Review Comment:
If invokes Main directly, compile would be failed.
So i used `go reflect` to invoke Main
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]