-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (42 loc) · 872 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
46
47
48
49
50
51
package main
import (
"net/http"
"os"
"runtime/debug"
"github.com/gorilla/mux"
"github.com/joho/godotenv"
"github.com/toppi-me/deployer/bot"
"github.com/toppi-me/deployer/handlers"
"github.com/toppi-me/deployer/internal/log"
)
func main() {
err := godotenv.Load(".env")
if err != nil {
panic(err)
}
err = bot.InitTelegramBot()
if err != nil {
panic(err)
}
r := mux.NewRouter()
{
handlers.GithubWebhook(r)
handlers.PingHandler(r)
}
err = http.ListenAndServe(
os.Getenv("HTTP_ADDR"), http.HandlerFunc(
func(w http.ResponseWriter, request *http.Request) {
defer func() {
if err := recover(); err != nil {
log.Error().Interface("err", err).Str("stack", string(debug.Stack())).Send()
return
}
}()
r.ServeHTTP(w, request)
},
),
)
if err != nil {
log.Warn().Err(err).Msg("server shut down")
}
}