-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (40 loc) · 954 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
52
53
package main
import (
"os"
"strings"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"webadisyon.com/db"
"webadisyon.com/routes"
)
func init() {
db.Setup()
}
func main() {
app := fiber.New()
app.Use(cors.New(cors.Config{
AllowOrigins: "*",
AllowHeaders: "*",
AllowMethods: "GET,POST,HEAD,PUT,DELETE,PATCH,OPTIONS",
//AllowCredentials: true,
}))
app.Use(InstallationCheck)
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World!")
})
routes.Routes(app)
app.Listen(":8080")
}
func InstallationCheck(c *fiber.Ctx) error {
installationDone := os.Getenv("INSTALLATION_DONE")
if installationDone != "true" {
// if path does not start with /inst
if !strings.HasPrefix(c.Path(), "/api/v1/install") {
return c.Status(403).JSON(fiber.Map{
"message": "Installation isnt done. Please finish installation.",
"redirect": "/install",
})
}
}
return c.Next()
}