Encadenamiento Condicional de controladores http en Golang
Quiero agregar un manejador http condicionalmente, basado en cierta condición. func ConditionalCheck(arg string) func(http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() check, ok := ctx.Value(“specific”).(bool) if check { SpecificCheck(arg) } else { next.ServeHTTP(w, r) } }) } } func SpecificCheck(arg string) . . . Read more