feat(logs): add logs for list handler
This commit is contained in:
2
main.go
2
main.go
@@ -149,6 +149,7 @@ func main() {
|
|||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.HandleFunc("/list", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/list", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log.Printf("request /list from %s [%s %s]", r.RemoteAddr, r.Method, r.UserAgent())
|
||||||
links := agg.List()
|
links := agg.List()
|
||||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||||
for i, link := range links {
|
for i, link := range links {
|
||||||
@@ -157,6 +158,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
_, _ = w.Write([]byte(link))
|
_, _ = w.Write([]byte(link))
|
||||||
}
|
}
|
||||||
|
log.Printf("response /list to %s: %d links", r.RemoteAddr, len(links))
|
||||||
})
|
})
|
||||||
|
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
|
|||||||
Reference in New Issue
Block a user