@@ -149,13 +149,17 @@ func main() {
149149// serveHome serves the main HTML page.
150150func serveHome (w http.ResponseWriter , r * http.Request ) {
151151 w .Header ().Set ("Content-Type" , "text/html" )
152- w .Write (indexHTML )
152+ if _ , err := w .Write (indexHTML ); err != nil {
153+ log .Printf ("Could not write response: %v" , err )
154+ }
153155}
154156
155157// getMapSources serves the available map sources as JSON.
156158func getMapSources (w http.ResponseWriter , r * http.Request ) {
157159 w .Header ().Set ("Content-Type" , "application/json" )
158- w .Write (mapSourcesJSON )
160+ if _ , err := w .Write (mapSourcesJSON ); err != nil {
161+ log .Printf ("Could not write response: %v" , err )
162+ }
159163}
160164
161165// wsHandler handles WebSocket connections.
@@ -703,7 +707,9 @@ func getCachedTiles(w http.ResponseWriter, r *http.Request) {
703707 }
704708
705709 w .Header ().Set ("Content-Type" , "application/json" )
706- json .NewEncoder (w ).Encode (cachedTiles )
710+ if err := json .NewEncoder (w ).Encode (cachedTiles ); err != nil {
711+ http .Error (w , fmt .Sprintf ("Error encoding cached tiles: %v" , err ), http .StatusInternalServerError )
712+ }
707713}
708714
709715// getStyleName returns the name of the map style for a given URL.
0 commit comments