go-cook/main.go

29 lines
492 B
Go

package main
import (
"database/sql"
v1 "go-cook/api/handlers/v1"
"log"
_ "github.com/glebarez/go-sqlite"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
db, err := sql.Open("sqlite", "gocook.db")
if err != nil {
log.Fatal(err)
}
e := echo.New()
e.Pre(middleware.RemoveTrailingSlash())
e.Pre(middleware.Logger())
v1Group := e.Group("/api/v1")
v1Api := v1.NewHandler(db)
v1Api.Register(v1Group)
e.Logger.Fatal(e.Start(":1323"))
}