Improve logging
This commit is contained in:
parent
17579b6f0b
commit
85b0cffdad
@ -32,10 +32,12 @@ func MakeVarnishList() []string {
|
|||||||
// PurgeHandler handles PURGE request to broadcast it to all varnish instances.
|
// PurgeHandler handles PURGE request to broadcast it to all varnish instances.
|
||||||
func PurgeHandler(w http.ResponseWriter, r *http.Request) {
|
func PurgeHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
url := r.URL.String()
|
url := r.URL.String()
|
||||||
|
remoteAddr := r.RemoteAddr
|
||||||
status := SendToVarnish(url)
|
status := SendToVarnish(url)
|
||||||
if status != "200 Purged" {
|
if status != "200 Purged" {
|
||||||
w.WriteHeader(405)
|
w.WriteHeader(405)
|
||||||
}
|
}
|
||||||
|
log.Println(remoteAddr + " Requested purge on " + url + " : " + status)
|
||||||
io.WriteString(w, status)
|
io.WriteString(w, status)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +61,6 @@ func SendToVarnish(url string) string {
|
|||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
status = "405 Not Allowed"
|
status = "405 Not Allowed"
|
||||||
}
|
}
|
||||||
log.Println("Purge " + domain + url + " : " + status)
|
|
||||||
}
|
}
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user