~xenrox/faceit_checker

19c809232670d16896dff3617bba2f8c02ebca0d — Thorben Günther 1 year, 2 months ago 176aae3
Check WriteString errors
1 files changed, 12 insertions(+), 3 deletions(-)

M faceit.go
M faceit.go => faceit.go +12 -3
@@ 400,15 400,24 @@ func (fc *faceitChecker) getElo(w http.ResponseWriter, r *http.Request) {
			} else {
				fc.logger.Errorf("getElo: %v", err)
				w.WriteHeader(http.StatusInternalServerError)
				io.WriteString(w, `{"Msg": Internal Server Error}`)
				_, err = io.WriteString(w, `{"Msg": Internal Server Error}`)
				if err != nil {
					fc.logger.Errorf("getElo: %v", err)
				}
				return
			}
		} else {
			w.WriteHeader(404)
			io.WriteString(w, `{"Msg": Faulty steamID64}`)
			_, err := io.WriteString(w, `{"Msg": Faulty steamID64}`)
			if err != nil {
				fc.logger.Errorf("getElo: %v", err)
			}
			return
		}
	}

	io.WriteString(w, fmt.Sprintf(`{"Elo": %d}`, data.Games.CSGO.Elo))
	_, err = io.WriteString(w, fmt.Sprintf(`{"Elo": %d}`, data.Games.CSGO.Elo))
	if err != nil {
		fc.logger.Errorf("getElo: %v", err)
	}
}