package interceptor

import (
	"github.com/gin-gonic/gin"
	"github.com/tidbcloud/observability/pkg/common/configs"
	"github.com/tidbcloud/observability/pkg/common/constants"
)

func UseRDS(c *gin.Context) {
	bizType := c.GetHeader(string(constants.OpenAPIHeaderBizType))
	if bizType == "" {
		bizType = c.Param("bizType")
	}
	if bizType != "" {
		conf, ok := configs.GetServiceInfo().BizTypeConfigs[bizType]
		if ok && conf.UseRDS {
			c.Set(constants.UseRDSKey, true)
		}
	}
	c.Next()
}
