Exemple #1
0
// FromContext retrieves the Env from the Context. If one isn't found, an error
// is returned.
func FromContext(ctx context.Context) (*Env, error) {
	if e, ok := ctx.Value(contextEnvKey).(*Env); ok {
		return e, nil
	}
	return nil, ctxerr.Wrap(ctx, errEnvNotFound)
}
Exemple #2
0
// ContextConfig returns the config from the context.
func ContextConfig(ctx context.Context) Config {
	ac, _ := ctx.Value(configKey).(Config)
	return ac
}
Exemple #3
0
// ContextParams extracts out the params from the context if possible.
func ContextParams(ctx context.Context) httprouter.Params {
	p, _ := ctx.Value(contextParamsKey).(httprouter.Params)
	return p
}