chore: reorganize common package

This commit is contained in:
JustSong
2024-04-06 02:03:59 +08:00
parent f586ae0ad8
commit 0b8ccb94eb
29 changed files with 167 additions and 167 deletions

View File

@@ -3,7 +3,7 @@ package middleware
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/songquanpeng/one-api/common"
"github.com/songquanpeng/one-api/common/config"
"github.com/songquanpeng/one-api/common/logger"
"github.com/songquanpeng/one-api/model"
"github.com/songquanpeng/one-api/relay/channeltype"
@@ -34,7 +34,7 @@ func Distribute() func(c *gin.Context) {
abortWithMessage(c, http.StatusBadRequest, "无效的渠道 Id")
return
}
if channel.Status != common.ChannelStatusEnabled {
if channel.Status != model.ChannelStatusEnabled {
abortWithMessage(c, http.StatusForbidden, "该渠道已被禁用")
return
}
@@ -68,18 +68,18 @@ func SetupContextForSelectedChannel(c *gin.Context, channel *model.Channel, mode
// this is for backward compatibility
switch channel.Type {
case channeltype.Azure:
c.Set(common.ConfigKeyAPIVersion, channel.Other)
c.Set(config.KeyAPIVersion, channel.Other)
case channeltype.Xunfei:
c.Set(common.ConfigKeyAPIVersion, channel.Other)
c.Set(config.KeyAPIVersion, channel.Other)
case channeltype.Gemini:
c.Set(common.ConfigKeyAPIVersion, channel.Other)
c.Set(config.KeyAPIVersion, channel.Other)
case channeltype.AIProxyLibrary:
c.Set(common.ConfigKeyLibraryID, channel.Other)
c.Set(config.KeyLibraryID, channel.Other)
case channeltype.Ali:
c.Set(common.ConfigKeyPlugin, channel.Other)
c.Set(config.KeyPlugin, channel.Other)
}
cfg, _ := channel.LoadConfig()
for k, v := range cfg {
c.Set(common.ConfigKeyPrefix+k, v)
c.Set(config.KeyPrefix+k, v)
}
}