mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-19 04:40:52 +08:00
fix(api): update route patterns to support wildcards for Gemini actions
Normalize action handling by accommodating wildcard patterns in route definitions for Gemini endpoints. Adjust `request.Action` parsing logic to correctly process routes with prefixed actions.
This commit is contained in:
@@ -267,7 +267,7 @@ func (m *AmpModule) registerProviderAliases(engine *gin.Engine, baseHandler *han
|
|||||||
v1betaAmp := provider.Group("/v1beta")
|
v1betaAmp := provider.Group("/v1beta")
|
||||||
{
|
{
|
||||||
v1betaAmp.GET("/models", geminiHandlers.GeminiModels)
|
v1betaAmp.GET("/models", geminiHandlers.GeminiModels)
|
||||||
v1betaAmp.POST("/models/:action", fallbackHandler.WrapHandler(geminiHandlers.GeminiHandler))
|
v1betaAmp.POST("/models/*action", fallbackHandler.WrapHandler(geminiHandlers.GeminiHandler))
|
||||||
v1betaAmp.GET("/models/:action", geminiHandlers.GeminiGetHandler)
|
v1betaAmp.GET("/models/*action", geminiHandlers.GeminiGetHandler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,8 +330,8 @@ func (s *Server) setupRoutes() {
|
|||||||
v1beta.Use(AuthMiddleware(s.accessManager))
|
v1beta.Use(AuthMiddleware(s.accessManager))
|
||||||
{
|
{
|
||||||
v1beta.GET("/models", geminiHandlers.GeminiModels)
|
v1beta.GET("/models", geminiHandlers.GeminiModels)
|
||||||
v1beta.POST("/models/:action", geminiHandlers.GeminiHandler)
|
v1beta.POST("/models/*action", geminiHandlers.GeminiHandler)
|
||||||
v1beta.GET("/models/:action", geminiHandlers.GeminiGetHandler)
|
v1beta.GET("/models/*action", geminiHandlers.GeminiGetHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Root endpoint
|
// Root endpoint
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ func (h *GeminiAPIHandler) GeminiGetHandler(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch request.Action {
|
action := strings.TrimPrefix(request.Action, "/")
|
||||||
|
switch action {
|
||||||
case "gemini-3-pro-preview":
|
case "gemini-3-pro-preview":
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"name": "models/gemini-3-pro-preview",
|
"name": "models/gemini-3-pro-preview",
|
||||||
@@ -189,7 +190,7 @@ func (h *GeminiAPIHandler) GeminiHandler(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
action := strings.Split(request.Action, ":")
|
action := strings.Split(strings.TrimPrefix(request.Action, "/"), ":")
|
||||||
if len(action) != 2 {
|
if len(action) != 2 {
|
||||||
c.JSON(http.StatusNotFound, handlers.ErrorResponse{
|
c.JSON(http.StatusNotFound, handlers.ErrorResponse{
|
||||||
Error: handlers.ErrorDetail{
|
Error: handlers.ErrorDetail{
|
||||||
|
|||||||
Reference in New Issue
Block a user