mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-16 08:04:10 +00:00
chore: reorganize common package
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user