This commit is contained in:
Brieuc Dubois 2023-12-27 23:38:06 +01:00
parent 69df067520
commit 93b6abd22e
1 changed files with 8 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"log" "log"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
"git.bhasher.com/bhasher/focus/backend/db" "git.bhasher.com/bhasher/focus/backend/db"
@ -15,6 +16,7 @@ func main() {
driver := "sqlite3" driver := "sqlite3"
connStr := "db.sqlite" connStr := "db.sqlite"
port := "3000" port := "3000"
origins := "*"
if err := db.InitDB(driver, connStr); err != nil { if err := db.InitDB(driver, connStr); err != nil {
log.Fatal(err) log.Fatal(err)
@ -22,6 +24,12 @@ func main() {
app := fiber.New() app := fiber.New()
app.Use(cors.New(cors.Config{
AllowOrigins: origins,
AllowMethods: "GET,POST,PUT,DELETE",
AllowHeaders: "Origin, Content-Type, Accept",
}))
app.Get("/projects", handlers.GetAllProjects) app.Get("/projects", handlers.GetAllProjects)
app.Get("/project/:id", handlers.GetProject) app.Get("/project/:id", handlers.GetProject)
app.Post("/project", handlers.CreateProject) app.Post("/project", handlers.CreateProject)