MCPcopy Create free account
hub / github.com/apache/openwhisk-cli / getPathParameterNames

Function getPathParameterNames

commands/api.go:106–129  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

104}
105
106func getPathParameterNames(path string) ([]string, error) {
107 var pathParameters []string
108
109 regexObj, err := regexp.Compile(pathSegmentParamRegex)
110 if err != nil {
111 whisk.Debug(whisk.DbgError, "Failed to match path '%s' to regular expressions `%s`\n", path, pathSegmentParamRegex)
112 } else {
113 segments := strings.Split(path, "/")
114 for _, segment := range segments {
115 segment = fmt.Sprintf("/%s/", segment)
116 matchedItems := regexObj.FindAllStringSubmatch(segment, -1)
117 for _, matchedParam := range matchedItems {
118 for idx, paramName := range matchedParam {
119 whisk.Debug(whisk.DbgInfo, "Path parameter submatch '%v'; idx %v\n", paramName, idx)
120 if idx > 0 && len(paramName) > 0 {
121 pathParameters = append(pathParameters, paramName)
122 }
123 }
124 }
125 }
126 }
127
128 return pathParameters, err
129}
130
131func hasPathParameters(path string) (bool, error) {
132 pathParams, err := getPathParameterNames(path)

Callers 2

hasPathParametersFunction · 0.85
generatePathParametersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected