This commit is contained in:
42
manifest.go
Normal file
42
manifest.go
Normal file
@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type File struct {
|
||||
Path string `json:"Path"`
|
||||
Hash string `json:"Hash"`
|
||||
Size int `json:"Size"`
|
||||
Custom bool `json:"Custom"`
|
||||
URL string `json:"URL"`
|
||||
Origin string `json:"Origin"`
|
||||
}
|
||||
|
||||
type Manifest struct {
|
||||
Version string `json:"Version"`
|
||||
Files []File `json:"Files"`
|
||||
}
|
||||
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user