Documentation ¶
Index ¶
- func ContextWithParamStorers(ctx context.Context, params ...ParamStorer) context.Context
- func ContextWithSafeAndUnsafeParams(ctx context.Context, safeParams, unsafeParams map[string]interface{}) context.Context
- func ContextWithSafeParam(ctx context.Context, key string, value interface{}) context.Context
- func ContextWithSafeParams(ctx context.Context, safeParams map[string]interface{}) context.Context
- func ContextWithUnsafeParam(ctx context.Context, key string, value interface{}) context.Context
- func ContextWithUnsafeParams(ctx context.Context, unsafeParams map[string]interface{}) context.Context
- func SafeAndUnsafeParamsFromContext(ctx context.Context) (safeParams map[string]interface{}, unsafeParams map[string]interface{})
- type ParamStorer
- func NewParamStorer(paramStorers ...ParamStorer) ParamStorer
- func NewSafeAndUnsafeParamStorer(safeParams, unsafeParams map[string]interface{}) ParamStorer
- func NewSafeParam(key string, value interface{}) ParamStorer
- func NewSafeParamStorer(safeParams map[string]interface{}) ParamStorer
- func NewUnsafeParam(key string, value interface{}) ParamStorer
- func NewUnsafeParamStorer(unsafeParams map[string]interface{}) ParamStorer
- func ParamStorerFromContext(ctx context.Context) ParamStorer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithParamStorers ¶
func ContextWithParamStorers(ctx context.Context, params ...ParamStorer) context.Context
ContextWithParamStorers returns a copy of the provided context that contains all of the safe and unsafe parameters provided by the provided ParamStorers. If the provided context already has safe/unsafe params, the newly returned context will contain the result of merging the previous parameters with the provided parameters.
func ContextWithSafeAndUnsafeParams ¶
func ContextWithSafeAndUnsafeParams(ctx context.Context, safeParams, unsafeParams map[string]interface{}) context.Context
ContextWithSafeAndUnsafeParams returns a copy of the provided context that contains the provided safe and unsafe parameters. If the provided context already has safe/unsafe params, the newly returned context will contain the result of merging the previous parameters with the provided parameters.
func ContextWithSafeParam ¶
ContextWithSafeParam returns a copy of the provided context that contains the provided safe parameter. If the provided context already has safe/unsafe params, the newly returned context will contain the result of merging the previous parameters with the provided parameter.
func ContextWithSafeParams ¶
ContextWithSafeParams returns a copy of the provided context that contains the provided safe parameters. If the provided context already has safe/unsafe params, the newly returned context will contain the result of merging the previous parameters with the provided parameters.
func ContextWithUnsafeParam ¶
ContextWithUnsafeParam returns a copy of the provided context that contains the provided unsafe parameter. If the provided context already has safe/unsafe params, the newly returned context will contain the result of merging the previous parameters with the provided parameter.
func ContextWithUnsafeParams ¶
func ContextWithUnsafeParams(ctx context.Context, unsafeParams map[string]interface{}) context.Context
ContextWithUnsafeParams returns a copy of the provided context that contains the provided unsafe parameters. If the provided context already has safe/unsafe params, the newly returned context will contain the result of merging the previous parameters with the provided parameters.
func SafeAndUnsafeParamsFromContext ¶
func SafeAndUnsafeParamsFromContext(ctx context.Context) (safeParams map[string]interface{}, unsafeParams map[string]interface{})
SafeAndUnsafeParamsFromContext returns the safe and unsafe parameters stored in the ParamStorer returned by ParamStorerFromContext for the provided context. Returns nil maps if the provided context does not have a ParamStorer.
Types ¶
type ParamStorer ¶
type ParamStorer interface { SafeParams() map[string]interface{} UnsafeParams() map[string]interface{} }
ParamStorer is a type that stores safe and unsafe parameters. Keys should be unique across both SafeParams and UnsafeParams (that is, if a key occurs in one map, it should not occur in the other). For performance reasons, the maps returned by SafeParams and UnsafeParams are references to the underlying storage and should not be modified by the caller.
func NewParamStorer ¶
func NewParamStorer(paramStorers ...ParamStorer) ParamStorer
NewParamStorer returns a new ParamStorer that stores all of the params in the provided ParamStorer inputs. The params are added from the param storers in the order in which they are provided, and for each individual param storer all of the safe params are added before the unsafe params while maintaining key uniqueness across both safe and unsafe parameters. This means that, if the same parameter is provided by multiple ParamStorer inputs, the returned ParamStorer will have the key (including safe/unsafe type) and value as provided by the last ParamStorer (for example, if an unsafe key/value pair is provided by one ParamStorer and a later ParamStorer specifies a safe key/value pair with the same key, the returned ParamStorer will store the last safe key/value pair).
func NewSafeAndUnsafeParamStorer ¶
func NewSafeAndUnsafeParamStorer(safeParams, unsafeParams map[string]interface{}) ParamStorer
NewSafeAndUnsafeParamStorer returns a new ParamStorer that stores the provided safe parameters as SafeParams and the unsafe parameters as UnsafeParams. If the safeParams and unsafeParams have any keys in common, the key/value pairs in the unsafeParams will be used (the conflicting key/value pairs provided by safeParams will be ignored).
func NewSafeParam ¶ added in v1.2.0
func NewSafeParam(key string, value interface{}) ParamStorer
NewSafeParam returns a new ParamStorer that stores a single safe parameter.
func NewSafeParamStorer ¶
func NewSafeParamStorer(safeParams map[string]interface{}) ParamStorer
NewSafeParamStorer returns a new ParamStorer that stores the provided parameters as SafeParams.
func NewUnsafeParam ¶ added in v1.2.0
func NewUnsafeParam(key string, value interface{}) ParamStorer
NewUnsafeParam returns a new ParamStorer that stores a single unsafe parameter.
func NewUnsafeParamStorer ¶
func NewUnsafeParamStorer(unsafeParams map[string]interface{}) ParamStorer
NewUnsafeParamStorer returns a new ParamStorer that stores the provided parameters as UnsafeParams.
func ParamStorerFromContext ¶
func ParamStorerFromContext(ctx context.Context) ParamStorer
ParamStorerFromContext returns the ParamStorer stored in the provided context. Returns nil if the provided context does not contain a ParamStorer.