Refactor handler errors

This commit is contained in:
TwinProduction
2021-09-12 17:06:14 -04:00
parent d69df41ef0
commit d86afb2381
3 changed files with 10 additions and 17 deletions

View File

@@ -39,8 +39,7 @@ func responseTimeChartHandler(writer http.ResponseWriter, r *http.Request) {
case "24h":
from = time.Now().Truncate(time.Hour).Add(-24 * time.Hour)
default:
writer.WriteHeader(http.StatusBadRequest)
_, _ = writer.Write([]byte("Durations supported: 7d, 24h"))
http.Error(writer, "Durations supported: 7d, 24h", http.StatusBadRequest)
return
}
hourlyAverageResponseTime, err := storage.Get().GetHourlyAverageResponseTimeByKey(vars["key"], from, time.Now())