Created
July 22, 2020 03:48
-
-
Save parzibyte/49810a401c4b843a60674f85b00d3bf7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// En el encabezado del archivo, recuerda importar a mux | |
import ( | |
"github.com/gorilla/mux" | |
) | |
// ... | |
func middleware(siguienteManejador http.Handler) http.Handler { | |
return http.HandlerFunc( | |
func(w http.ResponseWriter, r *http.Request) { | |
// Aquí obtenemos el nombre de la ruta | |
nombreRuta := mux.CurrentRoute(r).GetName() | |
if nombreRuta == "obtener_fecha" { | |
siguienteManejador.ServeHTTP(w, r) | |
} else { | |
// Oh no, no puedes ir a otra ruta | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment