You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
376 B
20 lines
376 B
package util
|
|
|
|
import "context"
|
|
|
|
const (
|
|
RequestIdHttpHeader = "X-Request-ID"
|
|
RequestIDKey = "x-request-id"
|
|
)
|
|
|
|
func GetRequestID(ctx context.Context) string {
|
|
if ctx == nil {
|
|
return ""
|
|
}
|
|
id, _ := ctx.Value(RequestIDKey).(string)
|
|
return id
|
|
}
|
|
|
|
func WithRequestID(ctx context.Context, id string) context.Context {
|
|
return context.WithValue(ctx, RequestIDKey, id)
|
|
}
|