contextx

package
v0.0.0-...-df727ae Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const KeyCtx = "contextx"

KeyCtx is the key of contextx.

Variables

This section is empty.

Functions

func AddContextxMiddleware

func AddContextxMiddleware() gin.HandlerFunc

AddContextxMiddleware is used to add contextx middleware.

Types

type Contextx

type Contextx struct {
	context.Context
	*zap.Logger
}

Contextx extends google's context to support logging methods.

func Background

func Background() Contextx

Background returns a non-nil, empty Contextx. It is never canceled, has no values, and has no deadline.

func FromGin

func FromGin(c *gin.Context) (Contextx, error)

FromGin returns a Contextx from gin.Context.

func WithCancel

func WithCancel(parent Contextx) (Contextx, context.CancelFunc)

WithCancel returns a copy of the parent context with a new Done channel.

func WithLogger

func WithLogger(logger *zap.Logger) Contextx

WithLogger returns a copy of parent in which the value associated with key is val.

func WithTimeout

func WithTimeout(parent Contextx, d time.Duration) (Contextx, context.CancelFunc)

WithTimeout returns a copy of the parent context with the timeout adjusted to be no later than d.

func WithValue

func WithValue(parent Contextx, key, val interface{}) Contextx

WithValue returns a copy of parent in which the value associated with key is val.

Jump to

Keyboard shortcuts

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