diff --git a/Go/internal/handlers/endpoint/dashboard/notifications_handler.go b/Go/internal/handlers/endpoint/dashboard/notifications_handler.go index 1077e5842279c3a44535a971cca7379617bf710e..a20c98aced8accbcd98f66ccebf65ad704da3944 100644 --- a/Go/internal/handlers/endpoint/dashboard/notifications_handler.go +++ b/Go/internal/handlers/endpoint/dashboard/notifications_handler.go @@ -10,45 +10,48 @@ func NotificationsHandler(w http.ResponseWriter, r *http.Request) { switch r.Method { case http.MethodGet: handleNotifGetRequest(w, r) + case http.MethodDelete: + handleNotifDeleteRequest(w, r) + case http.MethodPost: + handleNotifPostRequest(w, r) default: - http.Error(w, "REST Method: "+r.Method+" not supported. Currently no methods are supported.", http.StatusNotImplemented) + http.Error(w, "REST Method: "+r.Method+" not supported.", http.StatusNotImplemented) return } } // handleGetRequest handles GET requests to retrieve readership dashboard for a specific language. func handleNotifGetRequest(w http.ResponseWriter, r *http.Request) { - //TODO::Complete HTTP Method Requests -} + // Check if the link wants to get one webhook or all webhooks, and respond accordingly -func AddNewWebhook(w http.ResponseWriter, r *http.Request) { - if r.Method == http.MethodPost { - // Add some webhook and return some id - } else { - http.Error(w, "REST Method: "+r.Method+" not supported. Currently no methods are supported.", http.StatusNotImplemented) - } -} + // Make system take JSON -func DeleteWebhook(w http.ResponseWriter, r *http.Request) { - if r.Method == http.MethodDelete { - // Delete a registered webhook - } else { - http.Error(w, "REST Method: "+r.Method+" not supported. Currently no methods are supported.", http.StatusNotImplemented) - } + // Then send ID back } -func ViewOneWebhook(w http.ResponseWriter, r *http.Request) { - if r.Method == http.MethodGet { - // Show one webhook - } else { - http.Error(w, "REST Method: "+r.Method+" not supported. Currently no methods are supported.", http.StatusNotImplemented) - } +func handleNotifDeleteRequest(w http.ResponseWriter, r *http.Request) { + // Given the id from the url, delete the request + + // Fetch the id from URL + + // Check if webhook with that id exists + + // exists: delete + // (optional) Ask for deletion + + // Perform deletion + // Reorder? } -func ViewAllWebhooks(w http.ResponseWriter, r *http.Request) { - if r.Method == http.MethodGet { - // Show all webhooks - } else { - http.Error(w, "REST Method: "+r.Method+" not supported. Currently no methods are supported.", http.StatusNotImplemented) - } +func handleNotifPostRequest(w http.ResponseWriter, r *http.Request) { + + // Get url + + // Check if url has an additional parameter + + // Has parameter + // + + // Has no parameter + // Show all webhooks }