diff --git a/hub/route/server.go b/hub/route/server.go index ee626cb7..d530684a 100644 --- a/hub/route/server.go +++ b/hub/route/server.go @@ -42,16 +42,20 @@ func Start(addr string, secret string) { cors := cors.New(cors.Options{ AllowedOrigins: []string{"*"}, - AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, + AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE"}, AllowedHeaders: []string{"Content-Type", "Authorization"}, MaxAge: 300, }) + root := chi.NewRouter().With(jsonContentType) + root.Get("/traffic", traffic) + root.Get("/logs", getLogs) + + r.Get("/", hello) r.Group(func(r chi.Router) { r.Use(cors.Handler, authentication) - r.With(jsonContentType).Get("/traffic", traffic) - r.With(jsonContentType).Get("/logs", getLogs) + r.Mount("/", root) r.Mount("/configs", configRouter()) r.Mount("/proxies", proxyRouter()) r.Mount("/rules", ruleRouter()) @@ -104,6 +108,10 @@ func authentication(next http.Handler) http.Handler { return http.HandlerFunc(fn) } +func hello(w http.ResponseWriter, r *http.Request) { + render.JSON(w, r, render.M{"hello": "clash"}) +} + func traffic(w http.ResponseWriter, r *http.Request) { render.Status(r, http.StatusOK)