mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-19 08:56:37 +08:00
fix: 支持 /mj-{mode} 路径
This commit is contained in:
parent
49df4b6eed
commit
2e595bdafb
@ -180,7 +180,7 @@ func RelaySwapFace(c *gin.Context) *dto.MidjourneyResponse {
|
|||||||
Description: "quota_not_enough",
|
Description: "quota_not_enough",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
requestURL := c.Request.URL.String()
|
requestURL := getMjRequestPath(c.Request.URL.String())
|
||||||
baseURL := c.GetString("base_url")
|
baseURL := c.GetString("base_url")
|
||||||
fullRequestURL := fmt.Sprintf("%s%s", baseURL, requestURL)
|
fullRequestURL := fmt.Sprintf("%s%s", baseURL, requestURL)
|
||||||
mjResp, _, err := service.DoMidjourneyHttpRequest(c, time.Second*60, fullRequestURL)
|
mjResp, _, err := service.DoMidjourneyHttpRequest(c, time.Second*60, fullRequestURL)
|
||||||
@ -260,7 +260,7 @@ func RelayMidjourneyTaskImageSeed(c *gin.Context) *dto.MidjourneyResponse {
|
|||||||
c.Set("channel_id", originTask.ChannelId)
|
c.Set("channel_id", originTask.ChannelId)
|
||||||
c.Request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", channel.Key))
|
c.Request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", channel.Key))
|
||||||
|
|
||||||
requestURL := c.Request.URL.String()
|
requestURL := getMjRequestPath(c.Request.URL.String())
|
||||||
fullRequestURL := fmt.Sprintf("%s%s", channel.GetBaseURL(), requestURL)
|
fullRequestURL := fmt.Sprintf("%s%s", channel.GetBaseURL(), requestURL)
|
||||||
midjResponseWithStatus, _, err := service.DoMidjourneyHttpRequest(c, time.Second*30, fullRequestURL)
|
midjResponseWithStatus, _, err := service.DoMidjourneyHttpRequest(c, time.Second*30, fullRequestURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -440,7 +440,7 @@ func RelayMidjourneySubmit(c *gin.Context, relayMode int) *dto.MidjourneyRespons
|
|||||||
}
|
}
|
||||||
|
|
||||||
//baseURL := common.ChannelBaseURLs[channelType]
|
//baseURL := common.ChannelBaseURLs[channelType]
|
||||||
requestURL := c.Request.URL.String()
|
requestURL := getMjRequestPath(c.Request.URL.String())
|
||||||
|
|
||||||
baseURL := c.GetString("base_url")
|
baseURL := c.GetString("base_url")
|
||||||
|
|
||||||
@ -605,3 +605,15 @@ type taskChangeParams struct {
|
|||||||
Action string
|
Action string
|
||||||
Index int
|
Index int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getMjRequestPath(path string) string {
|
||||||
|
requestURL := path
|
||||||
|
if strings.Contains(requestURL, "/mj-") {
|
||||||
|
urls := strings.Split(requestURL, "/mj/")
|
||||||
|
if len(urls) < 2 {
|
||||||
|
return requestURL
|
||||||
|
}
|
||||||
|
requestURL = "/mj/" + urls[1]
|
||||||
|
}
|
||||||
|
return requestURL
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user