package apiresponse

import (
	"context"

	"github.com/google/uuid"
)

const TraceIDHeader = "X-Trace-Id"

type ctxKey int

const traceIDKey ctxKey = iota

func WithTraceID(ctx context.Context, id string) context.Context {
	return context.WithValue(ctx, traceIDKey, id)
}

func TraceIDFromContext(ctx context.Context) string {
	id, _ := ctx.Value(traceIDKey).(string)
	return id
}

func GenerateTraceID() string {
	return uuid.NewString()
}
