-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (33 loc) · 774 Bytes
/
main.go
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
package main
import (
"encoding/json"
"github.com/vsaveliev/jira-to-slack/jira"
"log"
"net/http"
"os"
)
type Config struct {
Port string `json:"port"`
Token string `json:"token"`
JiraConfig jira.Config `json:"jira"`
}
func main() {
config := GetConfig()
jiraObject := jira.Jira{}
jiraObject.Config = config.JiraConfig
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
var webHook jira.WebHookEvent
json.NewDecoder(r.Body).Decode(&webHook)
go func() {
jiraObject.Process(webHook)
}()
})
log.Fatal(http.ListenAndServe(":"+config.Port, nil))
}
func GetConfig() Config {
config := Config{}
file, _ := os.Open("config.json")
json.NewDecoder(file).Decode(&config)
config.JiraConfig.Token = config.Token
return config
}