Skip to content

Instantly share code, notes, and snippets.

@parzibyte

parzibyte/get.go Secret

Created August 14, 2021 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/4f2d18ea1a66f13fe684143ab9b068ed to your computer and use it in GitHub Desktop.
Save parzibyte/4f2d18ea1a66f13fe684143ab9b068ed to your computer and use it in GitHub Desktop.
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