Esempio n. 1
0
// Vars returns the route variables for the current request, if any.
func Vars(r *http.Request) map[string]string {
	if rv := context.Get(r, varsKey); rv != nil {
		return rv.(map[string]string)
	}
	return nil
}
Esempio n. 2
0
// CurrentRoute returns the matched route for the current request, if any.
// This only works when called inside the handler of the matched route
// because the matched route is stored in the request context which is cleared
// after the handler returns, unless the KeepContext option is set on the
// Router.
func CurrentRoute(r *http.Request) *Route {
	if rv := context.Get(r, routeKey); rv != nil {
		return rv.(*Route)
	}
	return nil
}
Esempio n. 3
0
// Vars returns the route variables for the current request, if any.
func Device(r *http.Request) string {
	if rv := context.Get(r, "Device"); rv != nil {
		return rv.(string)
	}
	return ""
}