You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
852 B
Go

2 years ago
package main
import (
"fmt"
2 years ago
"log"
"github.com/ajikamaludin/go-fiber-rest/app/configs"
apiv1 "github.com/ajikamaludin/go-fiber-rest/routers/api/v1"
notfound "github.com/ajikamaludin/go-fiber-rest/routers/exception"
home "github.com/ajikamaludin/go-fiber-rest/routers/home"
2 years ago
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
2 years ago
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
app := fiber.New()
app.Use(recover.New())
app.Use(logger.New())
2 years ago
// default here : /
home.HomeRoutes(app)
// api route : api/v1
apiv1.ApiRoutes(app)
// handle 404
notfound.Routes(app)
2 years ago
config := configs.GetInstance()
listen := fmt.Sprintf(":%v", config.Appconfig.Port)
log.Fatal(app.Listen(listen))
2 years ago
}