26 lines
480 B
Go
26 lines
480 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
type Cdn interface {
|
|
// Purge url from CDN
|
|
Purge(url string)
|
|
}
|
|
|
|
// BunnyCDN
|
|
type BunnyCdn struct {
|
|
// Access Key
|
|
key string
|
|
}
|
|
|
|
func (cdn *BunnyCdn) Purge(url string) {
|
|
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", cdn.key)
|
|
_, _ = client.Do(req)
|
|
}
|