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
No related branches found
No related tags found
Loading
......@@ -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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment