MCPcopy Index your code
hub / github.com/coder/coder / aibridgeproxyHandler

Function aibridgeproxyHandler

enterprise/coderd/aibridgeproxy.go:24–50  ·  view source on GitHub ↗

aibridgeproxyHandler handles AI Bridge Proxy endpoints.

(api *API, middlewares ...func(http.Handler) http.Handler)

Source from the content-addressed store, hash-verified

22
23// aibridgeproxyHandler handles AI Bridge Proxy endpoints.
24func aibridgeproxyHandler(api *API, middlewares ...func(http.Handler) http.Handler) func(r chi.Router) {
25 return func(r chi.Router) {
26 r.Use(api.RequireFeatureMW(codersdk.FeatureAIBridge))
27 r.Use(middlewares...)
28
29 r.HandleFunc("/*", func(rw http.ResponseWriter, r *http.Request) {
30 // Check if the proxy is enabled.
31 if !api.DeploymentValues.AI.BridgeProxyConfig.Enabled.Value() {
32 httpapi.Write(r.Context(), rw, http.StatusNotFound, codersdk.Response{
33 Message: "AI Bridge Proxy is not enabled.",
34 })
35 return
36 }
37
38 // Check if the handler is registered.
39 if api.aibridgeproxydHandler == nil {
40 httpapi.Write(r.Context(), rw, http.StatusNotFound, codersdk.Response{
41 Message: "AI Bridge Proxy handler not mounted.",
42 })
43 return
44 }
45
46 // Strip the prefix and relay to the aibridgeproxyd handler.
47 http.StripPrefix("/api/v2/aibridge/proxy", api.aibridgeproxydHandler).ServeHTTP(rw, r)
48 })
49 }
50}

Callers 1

NewFunction · 0.85

Calls 5

WriteFunction · 0.92
RequireFeatureMWMethod · 0.80
ContextMethod · 0.65
ValueMethod · 0.45
ServeHTTPMethod · 0.45

Tested by

no test coverage detected