gocommon/commonctx/request_id.go
Matthieu 'JP' DERASSE d880059980
All checks were successful
continuous-integration/drone/push Build is passing
feat(middlewares): Continue adding std middlewares
2023-01-29 16:00:49 +00:00

19 lines
467 B
Go

package commonctx
import (
"context"
)
// AddRequestID will add the provided requestID in the context.
func AddRequestID(ctx context.Context, requestID string) context.Context {
return context.WithValue(ctx, ContextKey_RequestID, requestID)
}
// GetRequestID retrieve a requestID from the context.
func GetRequestID(ctx context.Context) *string {
if requestID := ctx.Value(ContextKey_RequestID); requestID != nil {
return requestID.(*string)
}
return nil
}