hugo-micropub/cdn.go

28 lines
514 B
Go
Raw Normal View History

package main
import (
"net/http"
)
type Cdn interface {
// Purge url from CDN
Purge(url string)
}
// BunnyCDN
type BunnyCdn struct {
// Access Key
key string
}
2019-12-24 11:29:14 +00:00
var bunnyCdnUrl = "https://bunnycdn.com"
2019-12-22 19:27:12 +00:00
func (cdn *BunnyCdn) Purge(url string) {
client := &http.Client{}
2019-12-24 11:29:14 +00:00
req, _ := http.NewRequest("POST", bunnyCdnUrl+"/api/purge?url="+url, nil)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("AccessKey", cdn.key)
_, _ = client.Do(req)
}