package contextx import ( "context" "errors" ) func WithRequestId(c context.Context, requestId string) context.Context { return context.WithValue(c, "request_id", requestId) } func RequestIdFrom(c context.Context) (string, error) { requestID, ok := c.Value("request_id").(string) if !ok { return "", errors.New("request_id not found in context") } return requestID, nil } func WithToken(c context.Context, token string) context.Context { return context.WithValue(c, "token", token) } func TokenFrom(c context.Context) (string, error) { token, ok := c.Value("token").(string) if !ok { return "", errors.New("token not found in context") } return token, nil }