From 253b43606a5ad061b6cca1242e4002ff36754b32 Mon Sep 17 00:00:00 2001
From: Phrot Vedal <phrotv@stud.ntnu.no>
Date: Wed, 17 Apr 2024 15:30:49 +0200
Subject: [PATCH] "Added corresponding methods to the different request methods
 and added pseudo-code comments for each of the methods"

---
 .../dashboard/notifications_handler.go        | 59 ++++++++++---------
 1 file changed, 31 insertions(+), 28 deletions(-)

diff --git a/Go/internal/handlers/endpoint/dashboard/notifications_handler.go b/Go/internal/handlers/endpoint/dashboard/notifications_handler.go
index 1077e58..a20c98a 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
 }
-- 
GitLab