MCPcopy Create free account
hub / github.com/coder/aibridge / actorMiddleware

Function actorMiddleware

example/main.go:114–123  ·  view source on GitHub ↗

actorMiddleware injects actor identity into request context. In production, the user ID should be extracted from auth headers/tokens.

(next http.Handler)

Source from the content-addressed store, hash-verified

112// actorMiddleware injects actor identity into request context.
113// In production, the user ID should be extracted from auth headers/tokens.
114func actorMiddleware(next http.Handler) http.Handler {
115 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
116 userID := r.Header.Get("X-User-ID")
117 if userID == "" {
118 userID = "anonymous"
119 }
120 ctx := aibcontext.AsActor(r.Context(), userID, nil)
121 next.ServeHTTP(w, r.WithContext(ctx))
122 })
123}

Callers 1

mainFunction · 0.85

Calls 2

GetMethod · 0.80
ServeHTTPMethod · 0.80

Tested by

no test coverage detected