Working purge

This commit is contained in:
Sebastien Laithier 2023-05-10 09:33:13 +02:00
parent a6e66b316f
commit 8ef58bc9e8

17
main.go
View File

@ -1,22 +1,27 @@
package main
import (
"fmt"
"io"
"log"
"net/http"
)
// Declaring non-existing HTTP method
const (
MethodPurge = "PURGE"
VaultStgRoleId = ""
VaultStgSecretId = ""
MethodPurge = "PURGE"
)
// 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) {
client := &http.Client{}
// Retrieve URL sent and send an HTTP PURGE request to all varnish servers.
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() {