-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (32 loc) · 982 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
package main
import (
"github.com/abinba/codereview/database"
_ "github.com/abinba/codereview/docs"
"github.com/abinba/codereview/router"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/swagger"
)
func main() {
database.Connect()
app := fiber.New()
app.Use(logger.New())
app.Use(cors.New(cors.Config{
AllowOrigins: "http://localhost:8080", // your Vue.js frontend URL
AllowHeaders: "Origin, Content-Type, Accept, Authorization",
AllowMethods: "GET, POST, PUT, DELETE, OPTIONS",
AllowCredentials: true,
}))
router.SetupRoutes(app)
app.Get("/swagger/*", swagger.HandlerDefault) // default
app.Get("/swagger/*", swagger.New(swagger.Config{
URL: "http://example.com/doc.json",
DeepLinking: false,
DocExpansion: "none",
}))
app.Use(func(c *fiber.Ctx) error {
return c.SendStatus(404)
})
app.Listen(":3000")
}