MCPcopy
hub / github.com/caddyserver/caddy / serverNameFromContext

Function serverNameFromContext

modules/caddyhttp/metrics.go:289–295  ·  view source on GitHub ↗

serverNameFromContext extracts the current server name from the context. Returns "UNKNOWN" if none is available (should probably never happen).

(ctx context.Context)

Source from the content-addressed store, hash-verified

287// serverNameFromContext extracts the current server name from the context.
288// Returns "UNKNOWN" if none is available (should probably never happen).
289func serverNameFromContext(ctx context.Context) string {
290 srv, ok := ctx.Value(ServerCtxKey).(*Server)
291 if !ok || srv == nil || srv.name == "" {
292 return "UNKNOWN"
293 }
294 return srv.name
295}
296
297// metricsInstrumentedRoute wraps a compiled route Handler with metrics
298// instrumentation. It wraps the entire compiled route chain once,

Callers 2

ServeHTTPMethod · 0.85

Calls 1

ValueMethod · 0.45

Tested by 1