context.go
func ServerBaseContext(baseCtx context.Context, h http.Handler) http.Handler {
	fn := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		ctx := r.Context()
		baseCtx := baseCtx

		// Copy over default net/http server context keys
		if v, ok := ctx.Value(http.ServerContextKey).(*http.Server); ok {
			baseCtx = context.WithValue(baseCtx, http.ServerContextKey, v)
		}
		if v, ok := ctx.Value(http.LocalAddrContextKey).(net.Addr); ok {
			baseCtx = context.WithValue(baseCtx, http.LocalAddrContextKey, v)
		}

		h.ServeHTTP(w, r.WithContext(baseCtx))
	})
	return fn
}
func ServerBaseContext(baseCtx context.Context, h http.Handler) http.Handler {
	fn := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		ctx := r.Context()
		baseCtx := baseCtx

		// Copy over default net/http server context keys
		if v, ok := ctx.Value(http.ServerContextKey).(*http.Server); ok {
			baseCtx = context.WithValue(baseCtx, http.ServerContextKey, v)
		}
		if v, ok := ctx.Value(http.LocalAddrContextKey).(net.Addr); ok {
			baseCtx = context.WithValue(baseCtx, http.LocalAddrContextKey, v)
		}

		h.ServeHTTP(w, r.WithContext(baseCtx))
	})
	return fn
}
func ServerBaseContext ( baseCtx context . Context , h http . Handler ) http . Handler { fn := http . HandlerFunc ( func ( w http . ResponseWriter , r * http . Request ) { ctx := r . Context ( ) baseCtx := baseCtx // Copy over default net/http server context keys if v , ok := ctx . Value ( http . ServerContextKey ) . ( * http . Server ) ; ok { baseCtx = context . WithValue ( baseCtx , http . ServerContextKey , v ) } if v , ok := ctx . Value ( http . LocalAddrContextKey ) . ( net . Addr ) ; ok { baseCtx = context . WithValue ( baseCtx , http . LocalAddrContextKey , v ) } h . ServeHTTP ( w , r . WithContext ( baseCtx ) ) } ) return fn }
// ServerBaseContext wraps an http.Handler to set the request context to the
// `baseCtx`.
ServerBaseContext wraps an http . Handler to set the request context to the baseCtx .