Skip to content

Commit 238c537

Browse files
Fix not found
1 parent 83dc5b9 commit 238c537

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

controller/weather.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ func CurrentWeather(w http.ResponseWriter, r *http.Request) {
3131

3232
city := getCity(r)
3333
resp := getExternalWeather(city)
34+
if resp == nil {
35+
w.Header().Set("Content-Type", "application/json")
36+
w.WriteHeader(http.StatusNotFound)
37+
fmt.Fprintf(w, string(toJSON(model.ErrorMessage{Message: "NOT_FOUND"})))
38+
return
39+
}
3440
defer resp.Body.Close()
3541

3642
if resp.StatusCode == 200 {

0 commit comments

Comments
 (0)