hugo-micropub/bunnycdn.go

19 lines
423 B
Go
Raw Normal View History

package main
import (
"net/http"
)
func Purge(url string) {
accessKey, err := GetBunnyCDNKey()
if err != nil || len(accessKey) == 0 {
return
}
client := &http.Client{}
req, _ := http.NewRequest("POST", "https://bunnycdn.com/api/purge?url="+url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("AccessKey", accessKey)
_, _ = client.Do(req)
}