This repository was archived by the owner on Nov 3, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package handlers
2+
3+ import (
4+ "helios/config"
5+ "net/http"
6+
7+ "github.com/bytedance/sonic"
8+ )
9+
10+ func ResourcesHandler (w http.ResponseWriter , r * http.Request ) {
11+ if r .Method != http .MethodGet {
12+ http .Error (w , "Method not allowed" , http .StatusMethodNotAllowed )
13+ return
14+ }
15+
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+
24+ w .Header ().Set ("Content-Type" , "application/json" )
25+ sonic .ConfigDefault .NewEncoder (w ).Encode (resources )
26+ }
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ func main() {
4949 // 其他接口都需要认证中间件
5050 http .HandleFunc ("/api/search" , handlers .AuthMiddleware (handlers .SearchHandler ))
5151 http .HandleFunc ("/api/search/ws" , handlers .AuthMiddleware (handlers .SSESearchHandler ))
52+ http .HandleFunc ("/api/search/resources" , handlers .AuthMiddleware (handlers .ResourcesHandler ))
5253 http .HandleFunc ("/api/detail" , handlers .AuthMiddleware (handlers .DetailHandler ))
5354 http .HandleFunc ("/api/favorites" , handlers .AuthMiddleware (handlers .FavoritesHandler ))
5455 http .HandleFunc ("/api/searchhistory" , handlers .AuthMiddleware (handlers .SearchHistoryHandler ))
You can’t perform that action at this time.
0 commit comments