diff options
author | siddharth ravikumar <s@ricketyspace.net> | 2022-06-12 20:02:44 -0400 |
---|---|---|
committer | siddharth ravikumar <s@ricketyspace.net> | 2022-06-12 20:02:44 -0400 |
commit | eca00439fa896723176b0e3a8f873ef3f3213e4e (patch) | |
tree | a7ce2d237286b3e526a114291d274483b325c354 /main.go | |
parent | 59916c9462552a1826eeaddd62063f28716a1e30 (diff) |
peach: move around `serveStaticFile`
Diffstat (limited to 'main.go')
-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 { |