MCPcopy Create free account
hub / github.com/pace/bricks / FromCtx

Function FromCtx

locale/context.go:22–29  ·  view source on GitHub ↗

FromCtx returns the locale from the context. The returned locale is always not nil.

(ctx context.Context)

Source from the content-addressed store, hash-verified

20// FromCtx returns the locale from the context.
21// The returned locale is always not nil.
22func FromCtx(ctx context.Context) (*Locale, bool) {
23 val := ctx.Value(tokenKey)
24 if val == nil {
25 return new(Locale), false
26 }
27 l, ok := val.(*Locale)
28 return l, ok
29}
30
31// ContextTransfer sources the locale from the sourceCtx
32// and returns a new context based on the targetCtx

Callers 11

AddMethod · 0.92
RoundTripMethod · 0.92
TestLocaleRoundTripFunction · 0.92
TestPrepareContextFunction · 0.92
prepareClientContextFunction · 0.92
TestRun_transfersLocaleFunction · 0.92
TestContextFunction · 0.85
NewContextStrategyFunction · 0.85
ContextTransferFunction · 0.85
TestMiddlewareWithLocaleFunction · 0.85

Calls 1

ValueMethod · 0.80

Tested by 6

TestLocaleRoundTripFunction · 0.74
TestPrepareContextFunction · 0.74
TestRun_transfersLocaleFunction · 0.74
TestContextFunction · 0.68
TestMiddlewareWithLocaleFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…