echo-todos/main.go

37 lines
658 B
Go
Raw Permalink Normal View History

2024-08-19 12:56:20 +00:00
package main
import (
"log/slog"
"os"
"git.wittern.io/public/echo-todos/handler"
"git.wittern.io/public/echo-todos/pkg/db"
"git.wittern.io/public/echo-todos/view"
"github.com/joho/godotenv"
"github.com/labstack/echo/v4"
_ "github.com/mattn/go-sqlite3"
)
var Username = "My"
func main() {
WEBURL := "0.0.0.0:1337"
e := echo.New()
err := godotenv.Load()
Username = os.Getenv("USERNAME")
view.Username = Username
database, err := db.InitDB()
if err != nil {
slog.Error("failed to open database", "Error", err)
}
defer database.Close()
dbhandler := handler.DBHandler{DB: database}
handler.AddRoutes(dbhandler, e)
e.Start(WEBURL)
}