diff options
-rw-r--r-- | main.go | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -100,6 +100,17 @@ func showWeather(w http.ResponseWriter, lat, lng float32) { } } +func serveStaticFile(w http.ResponseWriter, r *http.Request) { + logRequest(r) + + // Add Cache-Control header + w.Header().Set("Cache-Control", "max-age=604800") + + // Serve. + server := http.FileServer(http.FS(peachFS)) + server.ServeHTTP(w, r) +} + func showSearch(w http.ResponseWriter, r *http.Request) { logRequest(r) @@ -119,17 +130,6 @@ func showSearch(w http.ResponseWriter, r *http.Request) { } } -func serveStaticFile(w http.ResponseWriter, r *http.Request) { - logRequest(r) - - // Add Cache-Control header - w.Header().Set("Cache-Control", "max-age=604800") - - // Serve. - server := http.FileServer(http.FS(peachFS)) - server.ServeHTTP(w, r) -} - func logRequest(r *http.Request) { addr := r.RemoteAddr if len(r.Header.Get("X-Forwarded-For")) > 0 { |