Working purge
This commit is contained in:
parent
a6e66b316f
commit
8ef58bc9e8
15
main.go
15
main.go
@ -1,22 +1,27 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Declaring non-existing HTTP method
|
|
||||||
const (
|
const (
|
||||||
MethodPurge = "PURGE"
|
MethodPurge = "PURGE"
|
||||||
VaultStgRoleId = ""
|
|
||||||
VaultStgSecretId = ""
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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) {
|
||||||
|
client := &http.Client{}
|
||||||
|
|
||||||
|
// Retrieve URL sent and send an HTTP PURGE request to all varnish servers.
|
||||||
url := r.URL.String()
|
url := r.URL.String()
|
||||||
io.WriteString(w, url)
|
req, err := http.NewRequest(MethodPurge, "http://10.13.32.1:6081" + url, nil)
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
fmt.Printf("Error: %v\n", err)
|
||||||
|
fmt.Printf("Resp: %v\n", resp)
|
||||||
|
io.WriteString(w, resp.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user