Skip to content

Commit 0084bdf

Browse files
committed
Check if airport is nil and throw 404
1 parent 6ac2f8e commit 0084bdf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

internal/v1/airport/public.go

+15
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ func getAirportATC(c *gin.Context) {
9191
return
9292
}
9393

94+
if airport == nil {
95+
response.RespondError(c, http.StatusNotFound, "Airport Not Found")
96+
return
97+
}
98+
9499
atc, err := database.FindAirportATCByID(airport.ID)
95100
if err != nil {
96101
response.RespondError(c, http.StatusInternalServerError, "Internal Server Error")
@@ -120,6 +125,11 @@ func getAirportCharts(c *gin.Context) {
120125
return
121126
}
122127

128+
if airport == nil {
129+
response.RespondError(c, http.StatusNotFound, "Airport Not Found")
130+
return
131+
}
132+
123133
charts, err := database.FindAirportChartsByID(airport.ID)
124134
if err != nil {
125135
response.RespondError(c, http.StatusInternalServerError, "Internal Server Error")
@@ -149,6 +159,11 @@ func getAirportWeather(c *gin.Context) {
149159
return
150160
}
151161

162+
if airport == nil {
163+
response.RespondError(c, http.StatusNotFound, "Airport Not Found")
164+
return
165+
}
166+
152167
d := &dto.AirportWeatherDTO{
153168
ID: airport.ICAO,
154169
}

0 commit comments

Comments
 (0)