context

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 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 Admin

func Admin(ctx context.Context) bool

Return the admin 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 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 ReqAdmin

func ReqAdmin(req *http.Request) bool

Return the admin parameter from a HTTP request, or zero value if not defined

func ReqName

func ReqName(req *http.Request) string

Return the name parameter from a HTTP request, or zero value if not defined

func ReqParams

func ReqParams(req *http.Request) []string

Return the parameters from a HTTP request, or nil if not defined

func ReqPrefix

func ReqPrefix(req *http.Request) string

Return the prefix parameter from a HTTP request, or zero value if not defined

func WithAddress

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

Return a context with the given address string

func WithAdmin

func WithAdmin(ctx context.Context, admin bool) context.Context

Return a context with the given admin flag

func WithCancel

func WithCancel() (context.Context, context.CancelFunc)

Return a context object with a function to cancel the context

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 WithPrefixParams

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

Return a context with the given prefix and parameters

Types

This section is empty.

Jump to

Keyboard shortcuts

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