Files
epochcli/pkg/epoch/manifest.go

52 lines
940 B
Go

package epoch
import (
"encoding/json"
"io"
"net/http"
)
const (
manifestUrl = "https://updater.project-epoch.net/api/v2/manifest"
)
type File struct {
Path string `json:"Path"`
Hash string `json:"Hash"`
Size int `json:"Size"`
Custom bool `json:"Custom"`
Urls struct {
Digitalocean string `json:"digitalocean"`
Cloudflare string `json:"cloudflare"`
None string `json:"none"`
} `json:"Urls"`
}
type Manifest struct {
Version string `json:"Version"`
UID string `json:"Uid"`
Files []File `json:"Files"`
CheckedAt string `json:"checked_at"`
}
func GetManifest() (*Manifest, error) {
resp, err := http.Get(manifestUrl)
if err != nil {
return nil, err
}
defer resp.Body.Close()
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var manifest Manifest
err = json.Unmarshal(data, &manifest)
if err != nil {
return nil, err
}
return &manifest, nil
}