From 535b320969fe509407946c297cf8b4016243fd65 Mon Sep 17 00:00:00 2001 From: andreacappelletti97 Date: Mon, 10 Apr 2023 15:12:02 -0500 Subject: [PATCH] Change request method from GET to POST --- dax/controller/http/handler.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dax/controller/http/handler.go b/dax/controller/http/handler.go index 9e427f010..4f0622915 100644 --- a/dax/controller/http/handler.go +++ b/dax/controller/http/handler.go @@ -25,7 +25,7 @@ func Handler(c *controller.Controller) http.Handler { router.HandleFunc("/database-by-name", server.postDatabaseByName).Methods("POST").Name("PostDatabaseByName") router.HandleFunc("/databases", server.postDatabases).Methods("POST").Name("PostDatabases") router.HandleFunc("/database/options", server.patchDatabaseOptions).Methods("PATCH").Name("PatchDatabaseOptions") - router.HandleFunc("/worker-count/{organization-id}/{database-id}", server.WorkerCount).Methods("GET").Name("DatabaseWorkers") + router.HandleFunc("/worker-count", server.WorkerCount).Methods("POST").Name("DatabaseWorkers") router.HandleFunc("/create-table", server.postCreateTable).Methods("POST").Name("PostCreateTable") router.HandleFunc("/drop-table", server.postDropTable).Methods("POST").Name("PostDropTable") @@ -217,13 +217,15 @@ func (s *server) patchDatabaseOptions(w http.ResponseWriter, r *http.Request) { // create a response struct func (s *server) WorkerCount(w http.ResponseWriter, r *http.Request) { - // get the context + body := r.Body + defer body.Close() + ctx := r.Context() - // get the id from the request - id := dax.QualifiedDatabaseID{ - OrganizationID: dax.OrganizationID(mux.Vars(r)["organization-id"]), - DatabaseID: dax.DatabaseID(mux.Vars(r)["database-id"]), + id := dax.QualifiedDatabaseID{} + if err := json.NewDecoder(body).Decode(&id); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return } // send the id into the controller, get the number of workers back