helper

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const PublicKeyNotSet = "not set"
View Source
const RequestIDPrefix string = "reqid://"

Variables

This section is empty.

Functions

func GetContextWithTimeout

func GetContextWithTimeout(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)

func GetDebug

func GetDebug(ctx context.Context) bool

GetDebug will get debug mode from a http request and return it

func GetFeatTag added in v0.0.13

func GetFeatTag() bool

func GetPublicKey added in v0.0.2

func GetPublicKey(ctx context.Context) string

GetPublicKey returns public key from the context

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID will get reqID from a http request and return it as a string

func GetResponseCode added in v0.0.3

func GetResponseCode(ctx context.Context) (int, error)

GetResponseCode returns http response status code from the context

func SetDebug

func SetDebug(ctx context.Context, debug bool) context.Context

SetDebug will set debug mode to a http request

func SetRandomRequestID

func SetRandomRequestID(ctx context.Context) context.Context

SetRandomRequestID will attach a brand new request ID to a http request

func SetRequestID

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

func SetResponseCode added in v0.0.3

func SetResponseCode(ctx context.Context, code int) context.Context

SetResponseCode sets http response status code on the context

Types

type ContextKey

type ContextKey string

ContextKey is used for context.Context value. The value requires a key that is not primitive type.

const ContextKeyRequestID ContextKey = "requestID"

ContextKeyRequestID is the ContextKey for RequestID

const PublicKey ContextKey = "userPublicKey"
const ResponseCode ContextKey = "responseCode"

type DebugKey

type DebugKey string
const Debug DebugKey = "debug"

Debug is the DebugKey for debug mode

Jump to

Keyboard shortcuts

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