fix: ignore uri query for service pattern matching

This commit is contained in:
Adrien Marquès 2021-06-22 22:45:47 +02:00
parent 2b67655cfd
commit fcc8b39717
Signed by: xdrm-brackets
GPG Key ID: D75243CA236D825E
1 changed files with 11 additions and 1 deletions

View File

@ -45,7 +45,17 @@ type BraceCapture struct {
// Match returns if this service would handle this HTTP request // Match returns if this service would handle this HTTP request
func (svc *Service) Match(req *http.Request) bool { func (svc *Service) Match(req *http.Request) bool {
return req.Method == svc.Method && svc.matchPattern(req.RequestURI) var (
uri = req.RequestURI
queryIndex = strings.IndexByte(uri, '?')
)
// remove query part for matching the pattern
if queryIndex > -1 {
uri = uri[:queryIndex]
}
return req.Method == svc.Method && svc.matchPattern(uri)
} }
// checks if an uri matches the service's pattern // checks if an uri matches the service's pattern