Esempio n. 1
0
// Get Token from the context
func GetToken(r *http.Request) string {
	return context.Get(r, TokenKey).(string)
}
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
// Get User from the context
func GetUserId(r *http.Request) string {
	return context.Get(r, UserKey).(string)
}
Esempio n. 4
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
}