package csrf import ( "context" ) type contextKey int8 const ( tokenContextKey contextKey = 1 ) func setCSRFToken(ctx context.Context, token string) context.Context { newCtx := context.WithValue(ctx, tokenContextKey, token) return newCtx } func GetCSRFToken(ctx context.Context) string { value := ctx.Value(tokenContextKey) strValue, ok := value.(string) if !ok { return "" } return strValue }