dubeejw commented on a change in pull request #170: Initial code checkin for
path parameter support
URL:
https://github.com/apache/incubator-openwhisk-cli/pull/170#discussion_r164937297
##########
File path: commands/api.go
##########
@@ -728,6 +750,44 @@ func getLargestApiNameSize(retApiArray
*whisk.RetApiArray, apiPath string, apiVe
return maxNameSize
}
+func validatePathParameters(relativePath string) error {
+ //openCount := strings.Count(relativePath, "{")
+ //closeCount := strings.Count(relativePath, "}")
+ regex := `/\{([^/]+)}/|/\{([^/]+)}$`
+ _, err := regexp.MatchString(regex, relativePath)
+ if err != nil {
+ errMsg := wski18n.T("Relative path '{{.path}}' does not include
valid path parameters. Each parameter must be enclosed in curly braces{}.",
+ map[string]interface{}{"path": relativePath})
+ whiskErr := whisk.MakeWskError(errors.New(errMsg),
whisk.EXIT_CODE_ERR_GENERAL,
+ whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
+ return whiskErr
+ }
+ return nil
+}
+
+func generatePathParameters(relativePath string) []whisk.ApiParameter {
+ pathParams := []whisk.ApiParameter{}
+ regex := `/\{([^/]+)}/|/\{([^/]+)}$`
Review comment:
Can `/\{([^/]+)}/|/\{([^/]+)}$` be a const? Seems like you use it a few
times.
----------------------------------------------------------------
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