package main import ( "fmt" "log" "net/http" "github.com/gin-gonic/gin" swaggerFiles "github.com/swaggo/files" ginSwagger "github.com/swaggo/gin-swagger" _ "github.com/timetracker/backend/docs" // This line is important for swag to work "github.com/timetracker/backend/internal/models" _ "gorm.io/driver/postgres" // GORM IMPORTS MARKER ) // @title Time Tracker API // @version 1.0 // @description This is a simple time tracker API. // @host localhost:8080 // @BasePath / // @Summary Say hello // @Description Get a hello message // @ID hello // @Produce plain // @Success 200 {string} string "Hello from the Time Tracker Backend!" // @Router / [get] func helloHandler(c *gin.Context) { c.String(http.StatusOK, "Hello from the Time Tracker Backend!") } func main() { dbConfig := models.DatabaseConfig{ Host: "localhost", Port: 5432, User: "postgres", Password: "password", DBName: "mydatabase", SSLMode: "disable", // Für Entwicklungsumgebung } // Datenbank initialisieren if err := models.InitDB(dbConfig); err != nil { log.Fatalf("Fehler bei der DB-Initialisierung: %v", err) } r := gin.Default() r.GET("/", helloHandler) r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) fmt.Println("Server listening on port 8080") r.Run(":8080") // Use Gin's Run method }