context

package
v1.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

The `context` package provides functions to embed parameters within a context object, and also functions to create contexts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address

func Address(ctx context.Context) string

Return the address parameter from the context, or zero value if not defined

func ContextForSignal

func ContextForSignal(signals ...os.Signal) context.Context

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

func Description(ctx context.Context) string

Return description from the context, zero value if not defined

func DumpContext

func DumpContext(ctx context.Context, w io.Writer)

Stringify the context values to an io.Writer object

func Label

func Label(ctx context.Context) string

Return the label parameter from the context, or zero value if not defined

func Name

func Name(ctx context.Context) string

Return the name parameter from the context, or zero value if not defined

func NameLabel

func NameLabel(ctx context.Context) string

Return the name and label parameter from the context, or zero value if not defined

func Path added in v1.1.1

func Path(ctx context.Context) string

Return the path parameter from the context, or zero value if not defined

func Prefix added in v1.1.3

func Prefix(ctx context.Context) string

Return the prefix parameter from the context, or zero value if not defined

func PrefixPathParams added in v1.1.3

func PrefixPathParams(ctx context.Context) (string, string, []string)

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 Scope added in v1.1.3

func Scope(ctx context.Context) []string

Return array of scopes from the context, or nil

func WithAddress

func WithAddress(ctx context.Context, addr string) context.Context

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

func WithDescription(ctx context.Context, description string) context.Context

Return a context with a description

func WithLabel added in v1.1.5

func WithLabel(ctx context.Context, label string) context.Context

Return a context with the given label

func WithName

func WithName(ctx context.Context, name string) context.Context

Return a context with the given name

func WithNameLabel

func WithNameLabel(ctx context.Context, name, label string) context.Context

Return a context with the given name and label

func WithPath added in v1.1.1

func WithPath(ctx context.Context, path string) context.Context

Return a context with the given path string

func WithPrefix added in v1.1.3

func WithPrefix(ctx context.Context, prefix string) context.Context

Return a context with the given prefix

func WithPrefixPathParams added in v1.1.3

func WithPrefixPathParams(ctx context.Context, prefix, path string, params []string) context.Context

Return a context with the given prefix and parameters

func WithScope added in v1.1.3

func WithScope(ctx context.Context, scope ...string) context.Context

Return a context with the given set of scopes

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL