From eca00439fa896723176b0e3a8f873ef3f3213e4e Mon Sep 17 00:00:00 2001 From: siddharth ravikumar Date: Sun, 12 Jun 2022 20:02:44 -0400 Subject: peach: move around `serveStaticFile` --- main.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index 36c4548..ed988c9 100644 --- a/main.go +++ b/main.go @@ -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 { -- cgit v1.2.3