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

createt structs for webhooks

parent fceecc86
Branches
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ func main() { ...@@ -23,7 +23,7 @@ func main() {
http.HandleFunc("/repocheck/v1/commits", assignment2.HandlerCommits) // runs handelr function http.HandleFunc("/repocheck/v1/commits", assignment2.HandlerCommits) // runs handelr function
http.HandleFunc("/repocheck/v1/languages", assignment2.HandlerLanguages) // runs handelr function http.HandleFunc("/repocheck/v1/languages", assignment2.HandlerLanguages) // runs handelr function
http.HandleFunc("/repocheck/v1/status", assignment2.HandlerStatus) // runs handelr function http.HandleFunc("/repocheck/v1/status", assignment2.HandlerStatus) // runs handelr function
// http.HandleFunc("/repocheck/v1/webhooks", assignment2.HandlerWebhooks) // runs handelr function http.HandleFunc("/repocheck/v1/webhooks", assignment2.WebhookHandeler) // runs handelr function
fmt.Println("Listening on port " + port) fmt.Println("Listening on port " + port)
log.Fatal(http.ListenAndServe(":"+port, nil)) log.Fatal(http.ListenAndServe(":"+port, nil))
} }
...@@ -11,7 +11,6 @@ import ( ...@@ -11,7 +11,6 @@ import (
func Counter(S []string) map[string]int { func Counter(S []string) map[string]int {
//List := strings.Fields(S)
count := make(map[string]int) count := make(map[string]int)
for _, Lang := range S { for _, Lang := range S {
_, ok := count[Lang] _, ok := count[Lang]
......
...@@ -51,3 +51,16 @@ type WebhookRegistration struct { ...@@ -51,3 +51,16 @@ type WebhookRegistration struct {
Event string `json:"event"` Event string `json:"event"`
URL string `json:"urk2` URL string `json:"urk2`
} }
type Webhooks struct {
ID int `json:"id"`
Event string `json:"Event"`
URL string `json:"url"`
Time float64 `json:"time"`
}
type WebhooksInvocation struct {
Event string `json:"event"`
Params []string `json:"params"`
Time float64 `json:"time"`
}
...@@ -50,6 +50,7 @@ func ServiceHandler(w http.ResponseWriter, r *http.Request) { ...@@ -50,6 +50,7 @@ func ServiceHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Method is invalid "+r.Method, http.StatusBadRequest) http.Error(w, "Method is invalid "+r.Method, http.StatusBadRequest)
} }
} }
func CallUrl(url string, content string) { func CallUrl(url string, content string) {
fmt.Println("Attempting invocation of url " + url + "...") fmt.Println("Attempting invocation of url " + url + "...")
res, err := http.Post(url, "string", bytes.NewReader([]byte(content))) res, err := http.Post(url, "string", bytes.NewReader([]byte(content)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment