MCPcopy Create free account
hub / github.com/compozy/agh / loopbackGuard

Function loopbackGuard

internal/api/httpapi/middleware.go:282–296  ·  view source on GitHub ↗
(boundHost string, guardErr error, openAICompatible bool)

Source from the content-addressed store, hash-verified

280}
281
282func loopbackGuard(boundHost string, guardErr error, openAICompatible bool) gin.HandlerFunc {
283 allowed := isLoopbackHost(canonicalHost(boundHost))
284 return func(c *gin.Context) {
285 if allowed {
286 c.Next()
287 return
288 }
289 if openAICompatible && isOpenAICompatiblePath(c) {
290 core.RespondOpenAIError(c, http.StatusForbidden, guardErr, false)
291 } else {
292 core.RespondError(c, http.StatusForbidden, guardErr, false)
293 }
294 c.Abort()
295 }
296}
297
298func isOpenAICompatiblePath(c *gin.Context) bool {
299 if c == nil || c.Request == nil || c.Request.URL == nil {

Callers 2

loopbackAPIGuardFunction · 0.85
loopbackMutationGuardFunction · 0.85

Calls 5

RespondOpenAIErrorFunction · 0.92
RespondErrorFunction · 0.92
isLoopbackHostFunction · 0.85
canonicalHostFunction · 0.85
isOpenAICompatiblePathFunction · 0.85

Tested by

no test coverage detected