aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/emicklei/go-restful/jsr311.go
diff options
context:
space:
mode:
authorGravatar Yong Tang <yong.tang.github@outlook.com> 2018-02-23 12:10:34 -0800
committerGravatar Miek Gieben <miek@miek.nl> 2018-02-23 20:10:34 +0000
commit604c0045e75e606e4bab9f1d57b3ba4eb75a2c31 (patch)
tree86213e326c230811bead2f7a79531f8f3eb5d795 /vendor/github.com/emicklei/go-restful/jsr311.go
parent9047bdf3a096907c47ee1d3787a63fde85a13b6e (diff)
downloadcoredns-604c0045e75e606e4bab9f1d57b3ba4eb75a2c31.tar.gz
coredns-604c0045e75e606e4bab9f1d57b3ba4eb75a2c31.tar.zst
coredns-604c0045e75e606e4bab9f1d57b3ba4eb75a2c31.zip
Update go dep (#1560)
This fix updates go dep with `dep ensure --update` as well as the following: - Removed github.com/ugorji/go restriction in Gopkg.toml (fixes #1557) - Added github.com/flynn/go-shlex in Makefile (neede by Caddy, maybe removed later) This fix fixes #1557 Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'vendor/github.com/emicklei/go-restful/jsr311.go')
-rw-r--r--vendor/github.com/emicklei/go-restful/jsr311.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/vendor/github.com/emicklei/go-restful/jsr311.go b/vendor/github.com/emicklei/go-restful/jsr311.go
index 9e8122416..4360b492e 100644
--- a/vendor/github.com/emicklei/go-restful/jsr311.go
+++ b/vendor/github.com/emicklei/go-restful/jsr311.go
@@ -39,6 +39,31 @@ func (r RouterJSR311) SelectRoute(
return dispatcher, route, ok
}
+// ExtractParameters is used to obtain the path parameters from the route using the same matching
+// engine as the JSR 311 router.
+func (r RouterJSR311) ExtractParameters(route *Route, webService *WebService, urlPath string) map[string]string {
+ webServiceExpr := webService.pathExpr
+ webServiceMatches := webServiceExpr.Matcher.FindStringSubmatch(urlPath)
+ pathParameters := r.extractParams(webServiceExpr, webServiceMatches)
+ routeExpr := route.pathExpr
+ routeMatches := routeExpr.Matcher.FindStringSubmatch(webServiceMatches[len(webServiceMatches)-1])
+ routeParams := r.extractParams(routeExpr, routeMatches)
+ for key, value := range routeParams {
+ pathParameters[key] = value
+ }
+ return pathParameters
+}
+
+func (RouterJSR311) extractParams(pathExpr *pathExpression, matches []string) map[string]string {
+ params := map[string]string{}
+ for i := 1; i < len(matches); i++ {
+ if len(pathExpr.VarNames) >= i {
+ params[pathExpr.VarNames[i-1]] = matches[i]
+ }
+ }
+ return params
+}
+
// http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2
func (r RouterJSR311) detectRoute(routes []Route, httpRequest *http.Request) (*Route, error) {
ifOk := []Route{}