Skip to content
Snippets Groups Projects
Commit 773c57bc authored by Hans Kristian Hoel's avatar Hans Kristian Hoel
Browse files

startet on invocation for webhooks

parent a6d48ffe
Branches
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"net/http" "net/http"
"sort" "sort"
"strconv" "strconv"
"time"
) )
func Counter(S []string) map[string]int { func Counter(S []string) map[string]int {
...@@ -136,6 +137,11 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) { ...@@ -136,6 +137,11 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
http.Header.Add(w.Header(), "Content-Type", "application/json") // makes the print look good http.Header.Add(w.Header(), "Content-Type", "application/json") // makes the print look good
Payload := &WebhooksInvocation{}
Payload.Event = "Language"
Payload.Time = time.Now()
Payload.Params = "Limit = " + limit + "and Auth = " + auth
json.NewEncoder(w).Encode(L) // encode L json.NewEncoder(w).Encode(L) // encode L
} }
...@@ -12,13 +12,12 @@ import ( ...@@ -12,13 +12,12 @@ import (
) )
var webhooks []WebhookRegistration //Webhook DB var webhooks []WebhookRegistration //Webhook DB
var IDNum = 1 var webhook = WebhookRegistration{}
/* /*
Handles webhook registration (POST) and lookup (GET) requests. Handles webhook registration (POST) and lookup (GET) requests.
Expects WebhookRegistration struct body in request. Expects WebhookRegistration struct body in request.
*/ */
var webhook = WebhookRegistration{}
func WebhookHandeler(w http.ResponseWriter, r *http.Request) { func WebhookHandeler(w http.ResponseWriter, r *http.Request) {
...@@ -32,8 +31,8 @@ func WebhookHandeler(w http.ResponseWriter, r *http.Request) { ...@@ -32,8 +31,8 @@ func WebhookHandeler(w http.ResponseWriter, r *http.Request) {
webhook.Time = time.Now() // sets time stamp webhook.Time = time.Now() // sets time stamp
FBSave() // saves webhook to firebase FBSave() // saves webhook to firebase
webhooks = append(webhooks, webhook) // saves webhook to webhooks //webhooks = append(webhooks, webhook) // saves webhook to webhooks ***************** look at this one
fmt.Fprintln(w, len(webhooks)-1) fmt.Fprintln(w, len(webhooks)-1)
fmt.Println("Webhooks " + webhook.URL + " has been regstrerd") fmt.Println("Webhooks " + webhook.URL + " has been regstrerd")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment