// match takes the topic string of the published message and does a basic compare to the
// string of the current Route, if they match it returns true
328041
func (r *route) match(topic string) bool {
	return r.topic == topic || routeIncludesTopic(r.topic, topic)
}
94916
func (g *Grok) Match(pattern, text string) (bool, error) {
	gr, err := g.compile(pattern)
	if err != nil {
		return false, err
	}

	if ok := gr.regexp.MatchString(text); !ok {
		return false, nil
	}

	return true, nil
}
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))
}
1060351
func (w *Wildmatch) Match(t string) bool {
	dirs, ok := w.consume(t, MatchOpts{})
	if !ok {
		return false
	}
	return len(dirs) == 0
}
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
}
581723
func (r *SimpleRouter) Match(ctx context.Context, match *RouteMatch) (bool, context.Context) {
	for _, route := range r.routes {
		var matched bool
		if matched, ctx = route.Match(ctx, match); matched {
			return true, ctx
		}
	}

	return false, ctx
}
1008486
func (this *Route) Match(method string, path string) (map[string]string, bool) {

	// If there is no Regex, compile one.
	if this.Regex == nil {
		this.Regex = this.CompileRegex(this.Path)
	}

	// Prime the params map.
	params := map[string]string{}

	// The string used for matching.
	matchPath := path

	// Test if this route matches the given "method" and "path".
	if method != this.Method || this.Regex.MatchString(matchPath) == false {
		return params, false
	}

	// Extract all params from the matched path.
	paramsList := this.Regex.FindAllStringSubmatch(path, -1)

	// For each found param, add it to the params map.
	for i, name := range this.ParamNames {
		params[name] = paramsList[0][i+1]
	}

	// Debug this stuff.
	// fmt.Println(this.Path)
	// fmt.Println(paramsList)
	// fmt.Println(params)
	// fmt.Println("")

	// Return the complete params map.
	return params, true
}
107283
func Match(ss *apps.StatefulSet, history *apps.ControllerRevision) (bool, error) {
	patch, err := getPatch(ss)
	if err != nil {
		return false, err
	}
	return bytes.Equal(patch, history.Data.Raw), nil
}
1292099
func (incident RunstatusIncident) Match(other RunstatusIncident) bool {
	if other.Title != "" && incident.Title == other.Title {
		return true
	}

	if other.ID > 0 && incident.ID == other.ID {
		return true
	}

	return false
}
1025368
func (s *Intention) Match(
	args *structs.IntentionQueryRequest,
	reply *structs.IndexedIntentionMatches) error {
	// Forward if necessary
	if done, err := s.srv.forward("Intention.Match", args, args, reply); done {
		return err
	}

	// Get the ACL token for the request for the checks below.
	rule, err := s.srv.ResolveToken(args.Token)
	if err != nil {
		return err
	}

	if rule != nil {
		// We go through each entry and test the destination to check if it
		// matches.
		for _, entry := range args.Match.Entries {
			if prefix := entry.Name; prefix != "" && !rule.IntentionRead(prefix) {
				s.srv.logger.Printf("[WARN] consul.intention: Operation on intention prefix '%s' denied due to ACLs", prefix)
				return acl.ErrPermissionDenied
			}
		}
	}

	return s.srv.blockingQuery(
		&args.QueryOptions,
		&reply.QueryMeta,
		func(ws memdb.WatchSet, state *state.Store) error {
			index, matches, err := state.IntentionMatch(ws, args.Match)
			if err != nil {
				return err
			}

			reply.Index = index
			reply.Matches = matches
			return nil
		},
	)
}
269063
func (t *Tree) Match(topic string) []interface{} {
	t.mutex.RLock()
	defer t.mutex.RUnlock()

	segments := strings.Split(topic, t.Separator)
	values := t.match([]interface{}{}, 0, segments, t.root)

	return t.clean(values)
}
1008294
func (m *matcher) match(line string) *Template {
	tmpl := m.root.search(line)
	if tmpl != nil {
		return tmpl
	}
	return m.defaultTemplate
}
210075
func (g *routeGroup) Match(methods []string, path string, h http.HandlerFunc) {
	for _, m := range methods {
		g.handle(m, path, h)
	}
}
75217
func (n *pathNode) match(path JsonPath) *pathNode {
	var node *pathNode = n
	for _, ps := range path {
		found := false
		for i, n := range node.childNodes {
			if n.matchOn == ps {
				node = &node.childNodes[i]
				found = true
				break
			} else if _, ok := ps.(int); ok && n.matchOn == AnyIndex {
				node = &node.childNodes[i]
				found = true
				break
			}
		}
		if !found {
			return nil
		}
	}
	return node
}
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))
}
921210
func (rule *PathCacheRule) matches(req *http.Request, statusCode int, respHeaders http.Header) bool {
	return strings.HasPrefix(req.URL.Path, rule.Path)
}
1335617
func (router *router) match(req *Request) (*Route, error) {
	// todo: consider using goroutines for searching for route

	method := req.Method
	path := req.URL.Path

	for _, route := range router.routes[method] {
		params, err := route.regex.Match(path)

		if err == nil {
			req.Params = params
			return &route, nil
		}
	}

	return nil, errors.New("[" + req.Method + "] handler for route " + path + " not found")
}