echo-todos/main.go
Alexilator 1d6fb15060
Some checks failed
Build Docker Image / build (push) Failing after 4m43s
cleanup and update
2025-01-30 22:58:27 +01:00

37 lines
718 B
Go

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)
slog.Info("Starting Webserver on port %w", "port", WEBURL)
e.Start(WEBURL)
}