MCPcopy Create free account
hub / github.com/bricks-cloud/BricksLLM / getProvider

Function getProvider

internal/server/web/proxy/middleware.go:125–156  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

123}
124
125func getProvider(c *gin.Context) string {
126 existing := c.GetString("provider")
127 if len(existing) != 0 {
128 return existing
129 }
130
131 parts := strings.Split(c.FullPath(), "/")
132
133 spaceRemoved := []string{}
134
135 for _, part := range parts {
136 if len(part) != 0 {
137 spaceRemoved = append(spaceRemoved, part)
138 }
139 }
140
141 if strings.HasPrefix(c.FullPath(), "/api/providers/") {
142 if len(spaceRemoved) >= 3 {
143 return spaceRemoved[2]
144 }
145 }
146
147 if strings.HasPrefix(c.FullPath(), "/api/custom/providers/") {
148 return c.Param("provider")
149 }
150
151 if strings.HasPrefix(c.FullPath(), "/api/routes/") {
152 return c.Param("provider")
153 }
154
155 return ""
156}
157
158type responseWriter struct {
159 gin.ResponseWriter

Callers 1

getMiddlewareFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected