Esempio n. 1
0
func (r *Router) Match(ctx *context.Context) (h handler.HandlerInterface, f bool) {
	var ng = map[string]string{}
	if r.regexp {
		var match bool
		ng, match = utils.NamedRegexpGroup(ctx.Request.URL.Path, r.regexPattern)
		if !match {
			return
		}
		ctx.AddParams(ng)
	} else {
		if ctx.Request.URL.Path != r.pattern {
			return
		}
	}
	f = true
	h = r.handler
	return
}
Esempio n. 2
0
// regexful route
// a => hello , b=>world when access GET /hello/world
func (h *NamedHandler) Get(c *context.Context) {
	var res = fmt.Sprintf("a=>%s,b=%s", c.Query("a"), c.Query("b"))
	c.ResponseWriter.Write([]byte(res))
}