some stuff from mac
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/yourusername/go-sqlc-jwt/config"
|
||||
@@ -13,22 +10,9 @@ import (
|
||||
"github.com/yourusername/go-sqlc-jwt/internal/middleware"
|
||||
)
|
||||
|
||||
func MainRouter() *gin.Engine {
|
||||
func MainRouter(queries *db.Queries) *gin.Engine {
|
||||
cfg := config.GetCfg()
|
||||
|
||||
dbConn, err := sql.Open("postgres", cfg.DB.DSN)
|
||||
if err != nil {
|
||||
log.Fatal("failed to connect to db:", err)
|
||||
}
|
||||
defer dbConn.Close()
|
||||
|
||||
// Configure database connection pool
|
||||
dbConn.SetMaxOpenConns(25)
|
||||
dbConn.SetMaxIdleConns(25)
|
||||
dbConn.SetConnMaxLifetime(5 * time.Minute)
|
||||
|
||||
queries := db.New(dbConn)
|
||||
|
||||
r := gin.Default()
|
||||
|
||||
authHandler := user.NewAuthHandler(queries, cfg.JWT.Secret)
|
||||
@@ -52,7 +36,7 @@ func MainRouter() *gin.Engine {
|
||||
})
|
||||
}
|
||||
|
||||
user.UserRouter(r)
|
||||
// user.UserRouter(r)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user