-
-
Save parzibyte/4f2d18ea1a66f13fe684143ab9b068ed 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
http.HandleFunc("/saludar", func(w http.ResponseWriter, r *http.Request) { | |
nombreArray, existeVariable := r.URL.Query()["nombre"] | |
if !existeVariable || len(nombreArray) <= 0 { | |
io.WriteString(w, "No proporcionaste ningún nombre") | |
} else { | |
nombre := nombreArray[0] | |
// Nota: "nombre" puede existir pero ser una cadena vacía, puedes revisar su longitud con len(nombre) | |
io.WriteString(w, "Hola, "+nombre) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment