-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (36 loc) · 991 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
package main
import (
"blacklist-service/config"
"blacklist-service/controllers"
"blacklist-service/database"
"blacklist-service/middlewares"
"flag"
"fmt"
"log"
"github.com/gofiber/fiber/v2"
)
var (
cfg *config.Config
app *fiber.App
)
func init() {
var path string
flag.StringVar(&path, "config", "config.yml", "Path to config file")
flag.Parse()
if newCfg, err := config.Init(path); err != nil {
log.Fatal(err)
} else {
cfg = newCfg
}
if err := database.Init(cfg.Database); err != nil {
log.Fatal(err)
}
}
func main() {
app = fiber.New()
app.Get("/guild/:id", middlewares.ClientAuthorization, controllers.GetGuildByID)
app.Post("/report/guild/:id", middlewares.ClientAuthorization, controllers.ReportGuildByID)
app.Get("/user/:id", middlewares.ClientAuthorization, controllers.GetGuildByID)
app.Post("/report/user/:id", middlewares.ClientAuthorization, controllers.ReportGuildByID)
log.Fatal(app.Listen(fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)))
}