Skip to content

Instantly share code, notes, and snippets.

@parzibyte

parzibyte/definir.go

Created Jul 22, 2020
Embed
What would you like to do?
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