es.davy.ai

Preguntas y respuestas de programación confiables

¿Tienes una pregunta?

Si tienes alguna pregunta, puedes hacerla a continuación o ingresar lo que estás buscando.

Tag: HTTPHANDLER

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