// 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) }
// ContextConfig returns the config from the context. func ContextConfig(ctx context.Context) Config { ac, _ := ctx.Value(configKey).(Config) return ac }
// 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 }