-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (38 loc) · 834 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 (
"log"
"os"
"time"
"github.com/44t4nk1/ffcc-backend/db"
"github.com/44t4nk1/ffcc-backend/middlewares"
"github.com/44t4nk1/ffcc-backend/routes"
"github.com/gin-gonic/gin"
cors "github.com/itsjamie/gin-cors"
)
var (
router = gin.Default()
)
func init() {
db.InitialiseDb()
rateLimiter := middlewares.RateLimitMiddleware()
router.Use(
cors.Middleware(
cors.Config{
Origins: "*",
Methods: "GET, PUT, POST, DELETE",
RequestHeaders: "Origin, Authorization, Content-Type",
ExposedHeaders: "",
MaxAge: 50 * time.Second,
Credentials: true,
ValidateHeaders: false,
}))
router.Use(rateLimiter)
routes.InitRoutes(router)
}
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
log.Fatal(router.Run(":" + port))
}