Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultToString(a any) string
- func GRPCMetadataPrefix() string
- func HTTPHeaderPrefix() string
- func Int(ctxKey any, stringKey string)
- func Int32(ctxKey any, stringKey string)
- func Int64(ctxKey any, stringKey string)
- func Log(format string, as ...any)
- func NoStandardDeadLine()
- func Reset()
- func Set(ctxKey any, stringKey string, parse ParseFunc, toString StringFunc)
- func SetGRPCMetadataPrefix(prefix string)
- func SetHTTPHeaderPrefix(prefix string)
- func SetLogger(logger LogFunc)
- func SetPrefixes(prefix string)
- func String(ctxKey any, stringKey string)
- func Time(ctxKey any, stringKey string)
- type Config
- type Entry
- type LogFunc
- type ParseFunc
- type StringFunc
Constants ¶
const DefaultHeaderPrefix = "X-Go-Context-"
DefaultHeaderPrefix is the default prefix for HTTP headers and gRPC metadata keys.
Variables ¶
var TimeFormat = time.RFC3339Nano
TimeFormat used for time.Time context values.
Functions ¶
func DefaultToString ¶
DefaultToString is a convenience wrapper around fmt.Sprintf.
func GRPCMetadataPrefix ¶
func GRPCMetadataPrefix() string
GRPCMetadataPrefix returns the prefix for gRPC metadata keys.
func HTTPHeaderPrefix ¶
func HTTPHeaderPrefix() string
HTTPHeaderPrefix returns the prefix for HTTP headers.
func NoStandardDeadLine ¶
func NoStandardDeadLine()
NoStandardDeadLine will disable propagation of the standard Go context deadline. By default, it is enabled.
func Reset ¶
func Reset()
Reset resets the configuration to its default state. It is mainly intended for unit tests. Normal code should have no reason to call this function.
func Set ¶
func Set(ctxKey any, stringKey string, parse ParseFunc, toString StringFunc)
Set adds an Entry with the given parameters. The parser function is required. If the stringer function is not provided, DefaultToString will be used.
func SetGRPCMetadataPrefix ¶
func SetGRPCMetadataPrefix(prefix string)
SetGRPCMetadataPrefix sets the prefix for gRPC metadata keys.
func SetHTTPHeaderPrefix ¶
func SetHTTPHeaderPrefix(prefix string)
SetHTTPHeaderPrefix sets the prefix for HTTP headers.
func SetLogger ¶
func SetLogger(logger LogFunc)
SetLogger sets the log function. Setting it to nil will disable logging.
func SetPrefixes ¶
func SetPrefixes(prefix string)
SetPrefixes sets the same header/metadata prefix for both HTTP/gRPC.
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
An Entry describes how to handle the serialisation and deserialisation of a context value.