mirror of
https://github.com/DullJZ/s3-balance.git
synced 2026-07-07 11:01:21 +08:00
Fix: Add CORS support for management API OPTIONS requests
This commit is contained in:
@@ -73,9 +73,10 @@ type HealthResponse struct {
|
||||
// RegisterRoutes 注册管理API路由
|
||||
// 注意: router 参数应该是已经带有 /api 前缀的子路由器
|
||||
func (h *AdminHandler) RegisterRoutes(router *mux.Router) {
|
||||
router.HandleFunc("/buckets", h.ListBuckets).Methods(http.MethodGet)
|
||||
router.HandleFunc("/buckets/{name}", h.GetBucketDetail).Methods(http.MethodGet)
|
||||
router.HandleFunc("/health", h.GetHealth).Methods(http.MethodGet)
|
||||
// 注册路由,同时支持 OPTIONS 方法用于 CORS 预检
|
||||
router.HandleFunc("/buckets", h.ListBuckets).Methods(http.MethodGet, http.MethodOptions)
|
||||
router.HandleFunc("/buckets/{name}", h.GetBucketDetail).Methods(http.MethodGet, http.MethodOptions)
|
||||
router.HandleFunc("/health", h.GetHealth).Methods(http.MethodGet, http.MethodOptions)
|
||||
}
|
||||
|
||||
// ListBuckets 获取存储桶列表
|
||||
|
||||
Reference in New Issue
Block a user