summaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorsiddharth ravikumar <s@ricketyspace.net>2022-06-12 20:02:44 -0400
committersiddharth ravikumar <s@ricketyspace.net>2022-06-12 20:02:44 -0400
commiteca00439fa896723176b0e3a8f873ef3f3213e4e (patch)
treea7ce2d237286b3e526a114291d274483b325c354 /main.go
parent59916c9462552a1826eeaddd62063f28716a1e30 (diff)
peach: move around `serveStaticFile`
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files 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 {