-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (37 loc) · 815 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
package main
import (
"fmt"
"github.com/cgauge/bot/cmd/api/database"
"github.com/cgauge/bot/cmd/api/handlers"
"github.com/cgauge/bot/cmd/api/routers"
"log"
"net/http"
"os"
"time"
)
const (
port = 8181
readTimeOut = 10 * time.Second
writeTimeout = 10 * time.Second
)
func main() {
log.Println("Starting Connection MySql")
db, err := database.ConnectDatabase()
if err != nil {
panic(err)
}
defer db.Close()
h := &handlers.Handler{DB: db}
routes := routers.Router(h)
s := &http.Server{
Addr: fmt.Sprintf(":%d", port),
Handler: routes,
ReadTimeout: readTimeOut,
WriteTimeout: writeTimeout,
}
log.Println("Starting ListenAndServe", port)
if err := s.ListenAndServe(); err != nil {
log.Println("Error in ListenAndServe. Error:", err)
os.Exit(1)
}
}