-
-
Save parzibyte/3b70589e56f1314f6a58c97aee0cc6dc 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
enrutador.HandleFunc("/usuario/{id}", obtenerUsuarioPorId).Methods("GET") | |
func obtenerUsuarioPorId(respuesta http.ResponseWriter, peticion *http.Request) { | |
variablesDePeticion := mux.Vars(peticion) | |
// El id viene como cadena, hay que convertirlo a entero de 32 bits | |
// Aquí "id" es la variable que indicamos en la ruta | |
idUsuarioBuscado, err := strconv.Atoi(variablesDePeticion["id"]) | |
// TODO: hacer algo con la variable | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment