// Match check if the request match the route Pattern
351104
func (r *Route) Match(req *http.Request) bool {
	ok, _ := r.matchAndParse(req)
	return ok
}
862961
func (pt *PathTemplate) Match(requestPath string) (bool, map[string]string) {
	if pt.PathTemplate == pt.httpHandlePath {
		// TODO ざっくりした実装なので後でリファクタリングすること
		if strings.HasPrefix(requestPath, pt.httpHandlePath) {
			return true, nil
		}
	}

	requestPathSplitted := strings.Split(requestPath, "/")
	if requiredLen, requestLen := len(pt.splittedPathTemplate), len(requestPathSplitted); requiredLen < requestLen {
		// I want to match /js/index.js to / :)
		requestPathSplitted = requestPathSplitted[0:requiredLen]
	} else if requiredLen != requestLen {
		return false, nil
	}

	params := make(map[string]string)
	for idx, s := range pt.splittedPathTemplate {
		reqPart := requestPathSplitted[idx]
		if pt.isVariables[idx] {
			if reqPart == "" {
				return false, nil
			}
			v, err := url.QueryUnescape(reqPart)
			if err != nil {
				v = reqPart
			}
			params[s[1:len(s)-1]] = v
		} else if s != reqPart {
			return false, nil
		} else {
			// match
		}
	}

	return true, params
}
426160
func (m Match) Match(position int) (string, error) {
	matches := m.Command.Expression().FindAllStringSubmatch(m.Request, -1)

	if len(matches) != 1 {
		return "", errors.New("Unable to parse request")
	}

	if position >= len(matches[0]) {
		return "", fmt.Errorf("No parameter at position %d", position)
	}

	return matches[0][position+1], nil
}
658386
func (msg *Message) Match(addr string) bool {
	exp := getRegEx(msg.Address)
	if exp.MatchString(addr) {
		return true
	}
	return false
}
926440
func (p Proxy) match(r *http.Request) Upstream {
	var u Upstream
	var longestMatch int
	for _, upstream := range p.Upstreams {
		basePath := upstream.From()
		if !httpserver.Path(r.URL.Path).Matches(basePath) || !upstream.AllowedPath(r.URL.Path) {
			continue
		}
		if len(basePath) > longestMatch {
			longestMatch = len(basePath)
			u = upstream
		}
	}
	return u
}
68550
func (req Request) Matches(tsti Info) bool {
	if !req.MessageImprint.Equal(tsti.MessageImprint) {
		return false
	}

	if req.Nonce != nil && tsti.Nonce == nil || req.Nonce.Cmp(tsti.Nonce) != 0 {
		return false
	}

	return true
}
1003174
func (r *routeRegexp) Match(req *http.Request, match *RouteMatch) bool {
	if !r.matchHost {
		if r.matchQuery {
			return r.regexp.MatchString(req.URL.RawQuery)
		} else {
			return r.regexp.MatchString(req.URL.Path)
		}
	}
	return r.regexp.MatchString(getHost(req))
}
763866
func (actionSet ActionSet) Match(action Action) bool {
	for r := range actionSet {
		if r.Match(action) {
			return true
		}
	}

	return false
}
565432
func (r *routeRegexp) Match(req *http.Request, match *RouteMatch) bool {
	if r.regexpType != regexpTypeHost {
		if r.regexpType == regexpTypeQuery {
			return r.matchQueryString(req)
		}
		path := req.URL.Path
		if r.options.useEncodedPath {
			path = req.URL.EscapedPath()
		}
		return r.regexp.MatchString(path)
	}

	return r.regexp.MatchString(getHost(req))
}
1215349
func (action Action) Match(a Action) bool {
	return wildcard.Match(string(action), string(a))
}
210075
func (g *routeGroup) Match(methods []string, path string, h http.HandlerFunc) {
	for _, m := range methods {
		g.handle(m, path, h)
	}
}
994289
func MatchPath(req *http.Request, ereq *Request) (bool, error) {
	if req.URL.Path == ereq.URLStruct.Path {
		return true, nil
	}
	return regexp.MatchString(ereq.URLStruct.Path, req.URL.Path)
}
203422
func MatchPathParams(req *http.Request, ereq *Request) (bool, error) {
	for key, value := range ereq.PathParams {
		var s string

		if err := parth.Sequent(req.URL.Path, key, &s); err != nil {
			return false, nil
		}

		if s != value {
			return false, nil
		}
	}
	return true, nil
}
588178
func (p Path) Matches(other string) bool {
	if CaseSensitivePath {
		return strings.HasPrefix(string(p), other)
	}
	return strings.HasPrefix(strings.ToLower(string(p)), strings.ToLower(other))
}
705901
func Matches(file string, patterns []string) (bool, error) {
	pm, err := NewPatternMatcher(patterns)
	if err != nil {
		return false, err
	}
	file = filepath.Clean(file)

	if file == "." {
		// Don't let them exclude everything, kind of silly.
		return false, nil
	}

	return pm.Matches(file)
}
869448
func Match(pattern string, b []byte) (matched bool, err error) {
	re, err := Compile(pattern)
	if err != nil {
		return false, err
	}
	return re.Match(b), nil
}
838604
func (r *Request) MatchParam(key, value string) *Request {
	query := r.URLStruct.Query()
	query.Set(key, value)
	r.URLStruct.RawQuery = query.Encode()
	return r
}