context

package
v0.0.0-...-1f9e35f Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package context provides functionality for wrapping values into the context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithValues

func ContextWithValues(ctx context.Context, v *Values) context.Context

ContextWithValues returns a new context with the provided values encapsulated.

func GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID returns the trace id from the context.

func SetStatusCode

func SetStatusCode(ctx context.Context, statusCode int) error

SetStatusCode sets the status code back into the context.

Types

type Values

type Values struct {
	TraceID    string
	Now        time.Time
	StatusCode int
}

Values represent a request's state.

func GetValues

func GetValues(ctx context.Context) (*Values, error)

GetValues returns the Values from the context. Returns an error is there's no or an invalid Values in the context.

Jump to

Keyboard shortcuts

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