mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-02 04:20:50 +08:00
34 lines
893 B
Go
34 lines
893 B
Go
package management
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/registry"
|
|
)
|
|
|
|
// GetStaticModelDefinitions returns static model metadata for a given channel.
|
|
// Channel is provided via path param (:channel) or query param (?channel=...).
|
|
func (h *Handler) GetStaticModelDefinitions(c *gin.Context) {
|
|
channel := strings.TrimSpace(c.Param("channel"))
|
|
if channel == "" {
|
|
channel = strings.TrimSpace(c.Query("channel"))
|
|
}
|
|
if channel == "" {
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": "channel is required"})
|
|
return
|
|
}
|
|
|
|
models := registry.GetStaticModelDefinitionsByChannel(channel)
|
|
if models == nil {
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": "unknown channel", "channel": channel})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"channel": strings.ToLower(strings.TrimSpace(channel)),
|
|
"models": models,
|
|
})
|
|
}
|