package filter import ( "ai-gateway/common/constant" "ai-gateway/infrastructure/repository" "ai-gateway/service" "net/http" "github.com/labstack/echo/v4" ) // UseLimit limit func UseLimit(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { corpId := c.Get(constant.CorpId).(uint64) bizId := c.Get(constant.BizId).(uint64) uid := c.Get(constant.UID).(uint64) ctx := repository.GetFbc(&c) breakLimit := service.ThirdApiLimit.BreakLimit(ctx, corpId, bizId, uid) if breakLimit { return c.JSON(http.StatusOK, map[string]interface{}{ "code": http.StatusNotAcceptable, "msg": "breaking the interface limit", }) } return next(c) } }