mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-19 18:16:38 +08:00
fix: use gin.BodyBytesKey as KeyRequestBody
This commit is contained in:
parent
95b4967f40
commit
215e59b76d
@ -1,5 +1,7 @@
|
||||
package ctxkey
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
const (
|
||||
Config = "config"
|
||||
Id = "id"
|
||||
@ -19,5 +21,6 @@ const (
|
||||
TokenName = "token_name"
|
||||
BaseURL = "base_url"
|
||||
AvailableModels = "available_models"
|
||||
KeyRequestBody = gin.BodyBytesKey
|
||||
SystemPrompt = "system_prompt"
|
||||
)
|
||||
|
@ -7,10 +7,11 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/songquanpeng/one-api/common/ctxkey"
|
||||
)
|
||||
|
||||
func GetRequestBody(c *gin.Context) ([]byte, error) {
|
||||
requestBody, _ := c.Get(gin.BodyBytesKey)
|
||||
requestBody, _ := c.Get(ctxkey.KeyRequestBody)
|
||||
if requestBody != nil {
|
||||
return requestBody.([]byte), nil
|
||||
}
|
||||
@ -19,7 +20,7 @@ func GetRequestBody(c *gin.Context) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
_ = c.Request.Body.Close()
|
||||
c.Set(gin.BodyBytesKey, requestBody)
|
||||
c.Set(ctxkey.KeyRequestBody, requestBody)
|
||||
return requestBody.([]byte), nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user