Documentation
¶
Overview ¶
The `context` package provides functions to embed parameters within a context object, and also functions to create contexts.
Index ¶
- func Address(ctx context.Context) string
- func ContextForSignal(signals ...os.Signal) context.Context
- func Description(ctx context.Context) string
- func DumpContext(ctx context.Context, w io.Writer)
- func Label(ctx context.Context) string
- func Name(ctx context.Context) string
- func NameLabel(ctx context.Context) string
- func Path(ctx context.Context) string
- func Prefix(ctx context.Context) string
- func PrefixPathParams(ctx context.Context) (string, string, []string)
- func RequireScope(handler http.HandlerFunc, enforced bool, scope ...string) http.HandlerFunc
- func Scope(ctx context.Context) []string
- func WithAddress(ctx context.Context, addr string) context.Context
- func WithCancel() (context.Context, context.CancelFunc)
- func WithDescription(ctx context.Context, description string) context.Context
- func WithName(ctx context.Context, name string) context.Context
- func WithNameLabel(ctx context.Context, name, label string) context.Context
- func WithPath(ctx context.Context, path string) context.Context
- func WithPrefix(ctx context.Context, prefix string) context.Context
- func WithPrefixPathParams(ctx context.Context, prefix, path string, params []string) context.Context
- func WithScope(ctx context.Context, scope ...string) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextForSignal ¶
ContextForSignal returns a context object which is cancelled when a signal is received. It returns nil if no signal parameter is provided
func Description ¶ added in v1.1.3
Return description from the context, zero value if not defined
func DumpContext ¶
Stringify the context values to an io.Writer object
func Path ¶ added in v1.1.1
Return the path parameter from the context, or zero value if not defined
func Prefix ¶ added in v1.1.3
Return the prefix parameter from the context, or zero value if not defined
func PrefixPathParams ¶ added in v1.1.3
Return prefix and parameters from the context
func RequireScope ¶ added in v1.1.3
func RequireScope(handler http.HandlerFunc, enforced bool, scope ...string) http.HandlerFunc
RequireScope returns a http.NotAutorized error if the request does not contain the required scope and the enforced flag is true
func WithAddress ¶
Return a context with the given address string
func WithCancel ¶
func WithCancel() (context.Context, context.CancelFunc)
Return a context object with a function to cancel the context
func WithDescription ¶ added in v1.1.3
Return a context with a description
func WithNameLabel ¶
Return a context with the given name and label
func WithPrefix ¶ added in v1.1.3
Return a context with the given prefix
Types ¶
This section is empty.