예제 #1
0
// setMatch extracts the variables from the URL once a route matches.
func (v *routeRegexp) setMatch(msg *coap.Message, m *RouteMatch, r *Route) {
	// Store path variables.
	pathVars := v.regexp.FindStringSubmatch(msg.PathString())
	if pathVars != nil {
		subexpNames := v.regexp.SubexpNames()
		varName := 0
		for i, name := range subexpNames[1:] {
			if name != "" && name == varGroupName(varName) {
				m.Vars[v.varsN[varName]] = pathVars[i+1]
				varName++
			}
		}

	}
}
예제 #2
0
// Match matches the regexp against the URL host or path.
func (r *routeRegexp) Match(msg *coap.Message, addr *net.UDPAddr) bool {
	return r.regexp.MatchString(msg.PathString())
}