From a772dcff4974b7a3c80daa2981393d5606755c0e Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Wed, 16 Sep 2020 19:13:44 +0800 Subject: [PATCH 1/2] unify route Signed-off-by: lhy1024 --- server/api/router.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/api/router.go b/server/api/router.go index fc2383bbfc0..c01a80a08ad 100644 --- a/server/api/router.go +++ b/server/api/router.go @@ -67,8 +67,9 @@ func createRouter(ctx context.Context, prefix string, svr *server.Server) *mux.R apiRouter.HandleFunc("/schedulers", schedulerHandler.Post).Methods("POST") apiRouter.HandleFunc("/schedulers/{name}", schedulerHandler.Delete).Methods("DELETE") apiRouter.HandleFunc("/schedulers/{name}", schedulerHandler.PauseOrResume).Methods("POST") + schedulerConfigHandler := newSchedulerConfigHandler(svr, rd) - rootRouter.PathPrefix(server.SchedulerConfigHandlerPath).Handler(schedulerConfigHandler) + apiRouter.PathPrefix("/scheduler-config").Handler(schedulerConfigHandler) clusterHandler := newClusterHandler(svr, rd) apiRouter.Handle("/cluster", clusterHandler).Methods("GET") From c6457729ab5a7fd608ede5cdc20ae678b935971b Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Wed, 16 Sep 2020 20:06:19 +0800 Subject: [PATCH 2/2] fix miss error in `redirectSchedulerDelete` Signed-off-by: lhy1024 --- server/api/scheduler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/api/scheduler.go b/server/api/scheduler.go index f8f0008b457..72cee53c043 100644 --- a/server/api/scheduler.go +++ b/server/api/scheduler.go @@ -264,12 +264,12 @@ func (h *schedulerHandler) redirectSchedulerDelete(name, schedulerName string) e args = args[len(args)-1:] url := fmt.Sprintf("%s/%s/%s/delete/%s", h.GetAddr(), schedulerConfigPrefix, schedulerName, args[0]) resp, err := doDelete(h.svr.GetHTTPClient(), url) - if resp.StatusCode != 200 { - return errs.ErrSchedulerNotFound.FastGenByArgs() - } if err != nil { return err } + if resp.StatusCode != http.StatusOK { + return errs.ErrSchedulerNotFound.FastGenByArgs() + } return nil }