Skip to content
Snippets Groups Projects
Commit 253b4360 authored by Phrot Vedal's avatar Phrot Vedal :computer:
Browse files

"Added corresponding methods to the different request methods and added...

"Added corresponding methods to the different request methods and added pseudo-code comments for each of the methods"
parent cc10a3c5
Branches
No related tags found
No related merge requests found
...@@ -10,45 +10,48 @@ func NotificationsHandler(w http.ResponseWriter, r *http.Request) { ...@@ -10,45 +10,48 @@ func NotificationsHandler(w http.ResponseWriter, r *http.Request) {
switch r.Method { switch r.Method {
case http.MethodGet: case http.MethodGet:
handleNotifGetRequest(w, r) handleNotifGetRequest(w, r)
case http.MethodDelete:
handleNotifDeleteRequest(w, r)
case http.MethodPost:
handleNotifPostRequest(w, r)
default: 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 return
} }
} }
// handleGetRequest handles GET requests to retrieve readership dashboard for a specific language. // handleGetRequest handles GET requests to retrieve readership dashboard for a specific language.
func handleNotifGetRequest(w http.ResponseWriter, r *http.Request) { 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) { // Make system take JSON
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)
}
}
func DeleteWebhook(w http.ResponseWriter, r *http.Request) { // Then send ID back
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)
}
} }
func ViewOneWebhook(w http.ResponseWriter, r *http.Request) { func handleNotifDeleteRequest(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet { // Given the id from the url, delete the request
// Show one webhook
} else { // Fetch the id from URL
http.Error(w, "REST Method: "+r.Method+" not supported. Currently no methods are supported.", http.StatusNotImplemented)
} // Check if webhook with that id exists
// exists: delete
// (optional) Ask for deletion
// Perform deletion
// Reorder?
} }
func ViewAllWebhooks(w http.ResponseWriter, r *http.Request) { func handleNotifPostRequest(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet {
// Get url
// Check if url has an additional parameter
// Has parameter
//
// Has no parameter
// Show all webhooks // Show all webhooks
} else {
http.Error(w, "REST Method: "+r.Method+" not supported. Currently no methods are supported.", http.StatusNotImplemented)
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment