MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / wouldMatch

Function wouldMatch

rest/routing.go:492–513  ·  view source on GitHub ↗
(router *mux.Router, rq *http.Request, method string)

Source from the content-addressed store, hash-verified

490}
491
492func wouldMatch(router *mux.Router, rq *http.Request, method string) (found bool, keyspace string) {
493 savedMethod := rq.Method
494 rq.Method = method
495 defer func() { rq.Method = savedMethod }()
496 var matchInfo mux.RouteMatch
497 found = router.Match(rq, &matchInfo)
498 // If a match is found, check for any db/keyspace path variable in the resolved match. Some paths may
499 // match routes with different path variables depending on the method.
500 if found {
501 matchVars := matchInfo.Vars
502 if dbName, ok := matchVars["db"]; ok {
503 keyspace = dbName
504 } else if keyspaceName, ok := matchVars["keyspace"]; ok {
505 keyspace = keyspaceName
506 } else if targetDbName, ok := matchVars["targetdb"]; ok {
507 keyspace = targetDbName
508 } else if newDbName, ok := matchVars["newdb"]; ok {
509 keyspace = newDbName
510 }
511 }
512 return found, keyspace
513}

Callers 1

wrapRouterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected