ctx

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetReqId

func GetReqId(c context.Context) string

GetReqId extract request id from given context. This is a shortcut for Get with ReqId to get the request id from given context.

func PassToContext added in v0.5.0

func PassToContext(c http.Context) context.Context

PassToContext pass Metadata from http.Context to context.

func Set added in v0.5.0

func Set(ctx context.Context, mt Metadata) context.Context

Set inject given Metadata to context with custom key to make sure that the value is correct.

func SetFromRequestHeader

func SetFromRequestHeader(c http.Context)

SetFromRequestHeader set any available metadata from given http context in the request header.

Types

type Metadata

type Metadata struct {
	Authorization   string
	UserAgent       string
	CacheControl    string
	ForwardedFor    string
	RequestFrom     string
	DeviceId        string
	App             string
	VersionApp      string
	ReqId           string
	ReqTags         string
	ReqUser         string
	ReqNama         string
	ReqKodeJabatan  string
	ReqNamaJabatan  string
	ReqKodeUker     string
	ReqNamaUker     string
	ReqJenisUker    string
	ReqKodeMainUker string
	ReqKodeRegion   string
	PathGateway     string
	ApiKey          string
}

Metadata holds any request-scoped shared data within brispot microservice.

func Get added in v0.5.0

func Get(ctx context.Context) Metadata

Get retrieve Metadata from given context with key from this pkg.

func ParseRequest

func ParseRequest(c http.Context) Metadata

ParseRequest return Metadata from given http context but return empty data instead if no data were found.

Jump to

Keyboard shortcuts

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