Пример #1
0
func AllLeagues(c context.Context, w http.ResponseWriter, r *http.Request) error {
	db := &internal.DSContext{c}
	lgs, err := db.GetAllLeagues()
	if err != nil {
		return err
	}
	return internal.Json(w, lgs)
}
Пример #2
0
func AllMatchesByLeague(c context.Context, w http.ResponseWriter, r *http.Request) error {
	vars := mux.Vars(r)
	l, err := strconv.Atoi(vars["league"])
	if err != nil {
		return err
	}
	s := vars["season"]
	db := &internal.DSContext{c}
	matches, err := db.GetAllMatchesByLeagueAndSeason(l, s)
	if err != nil {
		return err
	}

	return internal.Json(w, matches)
}