add Database type to cli and server config
This commit is contained in:
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"kontor-api-gin/internal/config"
|
||||
"kontor-api-gin/internal/handlers"
|
||||
"kontor-api-gin/internal/router"
|
||||
@@ -26,16 +25,8 @@ func main() {
|
||||
log.Fatalf("Failed to initialize config: %v", err)
|
||||
}
|
||||
|
||||
dsn := fmt.Sprintf(
|
||||
"host=%s user=%s password=%s dbname=%s port=%d sslmode=disable",
|
||||
viper.GetString("db.host"),
|
||||
viper.GetString("db.user"),
|
||||
viper.GetString("db.password"),
|
||||
viper.GetString("db.name"),
|
||||
viper.GetInt("db.port"),
|
||||
)
|
||||
|
||||
db, err := config.NewDB(dsn)
|
||||
db, err := config.NewDB()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -45,7 +36,7 @@ func main() {
|
||||
|
||||
// Set Gin mode based on environment
|
||||
// Production mode disables debug output
|
||||
if viper.GetString("gin.mode") == "release" {
|
||||
if config.ServerConfig.Gin.Mode == "release" {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
@@ -58,7 +49,7 @@ func main() {
|
||||
)
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: ":" + strconv.Itoa(viper.GetInt("port")),
|
||||
Addr: ":" + strconv.Itoa(config.ServerConfig.Server.Port),
|
||||
Handler: r,
|
||||
ReadHeaderTimeout: 5 * time.Second,
|
||||
WriteTimeout: 30 * time.Second,
|
||||
|
||||
Reference in New Issue
Block a user