diff options
author | siddharth ravikumar <s@ricketyspace.net> | 2022-06-02 22:32:50 -0400 |
---|---|---|
committer | siddharth ravikumar <s@ricketyspace.net> | 2022-06-02 22:32:50 -0400 |
commit | 9e9217cc81ec461576062cb291dbcb3cb74b85a5 (patch) | |
tree | 33cee61d0e39c590b4e1acb53b6eba5d0f6088b3 /main.go | |
parent | 874d37dcb70d6e20cf4acc11b9581e40002b562c (diff) |
peach: add logging
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -86,6 +86,8 @@ func main() { // default handler. http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + logRequest(r) + if r.URL.Path == "/" { http.Redirect(w, r, "/41.115,-83.177", 302) return @@ -149,6 +151,8 @@ func showWeather(w http.ResponseWriter, lat, lng float32) { } func showSearch(w http.ResponseWriter, r *http.Request) { + logRequest(r) + // Search is disabled if photon is not enabled. if !photon.Enabled() { http.NotFound(w, r) @@ -168,6 +172,8 @@ 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") @@ -257,3 +263,7 @@ func NewSearch(r *http.Request) (*Search, error) { } return s, nil } + +func logRequest(r *http.Request) { + log.Printf("%v - %v", r.RemoteAddr, r.URL) +} |