Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit 05b8a5c

Browse files
committed
ensure sources order
1 parent abd17b8 commit 05b8a5c

3 files changed

Lines changed: 3 additions & 9 deletions

File tree

config/subscription.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func FetchSubscription(url string) error {
4242
if len(config.APISites) == 0 {
4343
return fmt.Errorf("no API sites found in subscription")
4444
}
45+
config.SiteList = config.APISites
4546
for k, v := range config.APISites {
4647
v.Key = k
4748
config.APISites[k] = v

handlers/resources.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ func ResourcesHandler(w http.ResponseWriter, r *http.Request) {
1313
return
1414
}
1515

16-
// 将 map 转换为 list
17-
apiSites := config.GlobalConfig.APISites
18-
resources := make([]interface{}, 0, len(apiSites))
19-
20-
for _, site := range apiSites {
21-
resources = append(resources, site)
22-
}
23-
2416
w.Header().Set("Content-Type", "application/json")
25-
sonic.ConfigDefault.NewEncoder(w).Encode(resources)
17+
sonic.ConfigDefault.NewEncoder(w).Encode(config.GlobalConfig.SiteList)
2618
}

models/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package models
22

33
type Config struct {
44
APISites map[string]APISite `json:"api_site"`
5+
SiteList []APISite `json:"site_list"`
56
}
67

78
type APISite struct {

0 commit comments

Comments
 (0)