-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
46 lines (39 loc) · 974 Bytes
/
Copy pathmain.go
File metadata and controls
46 lines (39 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
"github.com/cbrgm/githubevents/githubevents"
"github.com/tjololo/mope/pkg/handlers"
"github.com/tjololo/mope/pkg/utils"
"net/http"
"os"
)
func main() {
utils.InitializeLogger()
defer utils.Logger.Sync()
secret := os.Getenv("GITHUB_WEBHOOK_SECRET")
handle := githubevents.New(secret)
handle.OnIssueCommentCreated(
handlers.HandleIssueCommentCreated,
)
handle.OnIssuesEventOpened(
handlers.HandleIssueOpenEvent,
)
handle.OnIssuesEventReopened(
handlers.HandleIssueOpenEvent,
)
handle.OnPullRequestEventOpened(
handlers.HandlePullReuqestOpened,
)
// add a http handleFunc
http.HandleFunc("/hook", func(w http.ResponseWriter, r *http.Request) {
r.Header.Add("Content-Type", "application/json")
err := handle.HandleEventRequest(r)
if err != nil {
fmt.Printf("error: %v\n", err)
}
})
// start the server listening on port 8080
if err := http.ListenAndServe(":8080", nil); err != nil {
panic(err)
}
}