appcontext

package
v0.0.36-pre4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

View Source
const (
	AcceptLanguage   contextKey = "AcceptLanguage"
	RequestID        contextKey = "RequestID"
	ServiceVersion   contextKey = "ServiceVersion"
	UserAgent        contextKey = "UserAgent"
	RequestStartTime contextKey = "RequestStartTime"
)

Variables

This section is empty.

Functions

func GetAcceptLanguage

func GetAcceptLanguage(ctx context.Context) language.Language

Get accept language from context and if not exists, this function will return `language.English` as default value

func GetRequestID

func GetRequestID(ctx context.Context) string

Get request id from context and will return empty string if not exist

func GetRequestStartTime

func GetRequestStartTime(ctx context.Context) time.Time

Get request start time from context will return zero value of `time.Time` if not exist

func GetServiceVersion

func GetServiceVersion(ctx context.Context) string

Get service version from context and will return empty string if not exist

func GetUserAgent

func GetUserAgent(ctx context.Context) string

Get user agent from context and will return empty string if not exist

func SetAcceptLanguage

func SetAcceptLanguage(ctx context.Context, lang language.Language) context.Context

Set accept language to context

func SetRequestID

func SetRequestID(ctx context.Context, id string) context.Context

Set request id to context

func SetRequestStartTime

func SetRequestStartTime(ctx context.Context, rst time.Time) context.Context

Set request start time to context

func SetServiceVersion

func SetServiceVersion(ctx context.Context, version string) context.Context

Set service version to context

func SetUserAgent

func SetUserAgent(ctx context.Context, ua string) context.Context

Set user agent to context

Types

This section is empty.

Jump to

Keyboard shortcuts

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