aboutsummaryrefslogtreecommitdiff
path: root/internal/sources/sources.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/sources/sources.go')
-rw-r--r--internal/sources/sources.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/sources/sources.go b/internal/sources/sources.go
new file mode 100644
index 0000000..3b82c5c
--- /dev/null
+++ b/internal/sources/sources.go
@@ -0,0 +1,46 @@
+// Copyright (c) 2026 Arslaan Pathan
+// This software is licensed under the ARPL. See LICENSE for details.
+
+package sources
+
+import (
+ "fmt"
+ "encoding/json"
+ "net/http"
+)
+
+type PackageListing struct {
+ Repository string `json:"repo"`
+ KiirofileOverride *string `json:"kiirofile_override"`
+ KiirotomlOverride *string `json:"kiirotoml_override"`
+}
+
+func FetchPackageListing(url string) (*PackageListing, error) {
+ fmt.Println("Fetching package listing...")
+
+ resp, err := http.Get(url)
+ if err != nil {
+ log.Fatal(err)
+ return nil, err
+ }
+
+ body, err := io.ReadAll(res.Body)
+ res.Body.Close()
+
+ if res.StatusCode > 299 {
+ log.Fatalf("Response failed with status code: %d", res.StatusCode)
+ return nil, err
+ }
+ if err != nil {
+ log.Fatal(err)
+ return nil, err
+ }
+
+ var packageListing PackageListing
+ err := json.Unmarshal(body, &packageListing)
+ if err != nil {
+ return nil, err
+ }
+ fmt.Println("Fetched package listing!")
+ return &packageListing, nil
+}