41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
_ "gitea.gabilandia.com/gabdlr/agenda-web-go/docs"
|
|
"gitea.gabilandia.com/gabdlr/agenda-web-go/internal/database"
|
|
"gitea.gabilandia.com/gabdlr/agenda-web-go/internal/handler"
|
|
"gitea.gabilandia.com/gabdlr/agenda-web-go/internal/repository"
|
|
httpSwagger "github.com/swaggo/http-swagger"
|
|
)
|
|
|
|
// @title Contacts API
|
|
// @version 1.0
|
|
// @description A simple Contacts CRUD API
|
|
// @termsOfService http://swagger.io/terms/
|
|
|
|
// @contact.name API Support
|
|
// @contact.email support@yourapp.com
|
|
|
|
// @license.name MIT
|
|
// @license.url https://opensource.org/licenses/MIT
|
|
|
|
// @host localhost:8080
|
|
// @BasePath /
|
|
func main() {
|
|
err := database.InitDB(database.Conn_string)
|
|
defer database.CloseDB()
|
|
if err != nil {
|
|
log.Fatal("Database connection failed:", err)
|
|
}
|
|
mux := http.NewServeMux()
|
|
|
|
contactRepo := repository.NewContactRepository(database.DB)
|
|
handler.HandleContacts(mux, contactRepo)
|
|
handler.HandlHealthChecks(mux)
|
|
mux.HandleFunc("/swagger/", httpSwagger.WrapHandler)
|
|
log.Fatal(http.ListenAndServe(":8080", mux))
|
|
}
|