Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created July 22, 2020 03:40
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/6ed5104f5d22d19f5436b2271c22e298 to your computer and use it in GitHub Desktop.
Save parzibyte/6ed5104f5d22d19f5436b2271c22e298 to your computer and use it in GitHub Desktop.
enrutador.HandleFunc("/dia_segun_fecha", func(w http.ResponseWriter, r *http.Request) {
variablesUrl := r.URL.Query()["fecha"]
if len(variablesUrl) <= 0 {
responderHttpConError(errors.New("no hay fecha en la URL"), w, r)
return
}
fecha := variablesUrl[0]
// 2006-01-02 es layout de YYYY-MM-DD. No modificar
t, err := time.Parse("2006-01-02", fecha)
if err != nil {
panic(err)
}
dia := Dias[t.Weekday()]
responderHttpExitoso(dia, w, r)
}).Name("obtener_fecha")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment