コード例 #1
0
func listAllTournaments(c web.C, w http.ResponseWriter, r *http.Request) *appError {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	tournamentList, err := tournaments.AllTournaments()
	if err != nil {
		return &appError{err, "Cant load tournaments", 500}
	}
	encoder := json.NewEncoder(w)
	encoder.Encode(tournamentList)
	return nil
}
コード例 #2
0
func listAllSeasons(c web.C, w http.ResponseWriter, r *http.Request) *appError {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	allTournaments, err := tournaments.AllTournaments()
	if err != nil {
		return &appError{err, "Cant load tournaments", 404}
	}

	seasonList := allTournaments.Seasons()
	sort.Ints(seasonList)
	encoder := json.NewEncoder(w)
	encoder.Encode(map[string][]int{"seasons": seasonList})
	return nil
}
コード例 #3
0
func getTotalTitles(c web.C, w http.ResponseWriter, r *http.Request) *appError {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	tList, err := tournaments.AllTournaments()
	if err != nil {
		return &appError{err, "Cant find tournaments", 404}
	}

	seasons := tList.Seasons()

	allTitles := tournaments.Titles(seasons)

	encoder := json.NewEncoder(w)
	encoder.Encode(allTitles)
	return nil
}