mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-05 02:41:41 +00:00
refactor: move session management to dedicated database module
This commit is contained in:
@@ -4,25 +4,19 @@ package gateway
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/gateway/config"
|
||||
"github.com/onsonr/sonr/internal/gateway/database"
|
||||
"github.com/onsonr/sonr/internal/gateway/context"
|
||||
"github.com/onsonr/sonr/internal/gateway/handlers/index"
|
||||
"github.com/onsonr/sonr/internal/gateway/handlers/register"
|
||||
"github.com/onsonr/sonr/internal/gateway/session"
|
||||
"github.com/onsonr/sonr/pkg/common/response"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func RegisterRoutes(e *echo.Echo, env config.Env) error {
|
||||
func RegisterRoutes(e *echo.Echo, env config.Env, db *gorm.DB) error {
|
||||
// Custom error handler for gateway
|
||||
e.HTTPErrorHandler = response.RedirectOnError("http://localhost:3000")
|
||||
|
||||
// Initialize database
|
||||
db, err := database.InitDB(env)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Inject session middleware with database connection
|
||||
e.Use(session.Middleware(db, env))
|
||||
e.Use(context.Middleware(db, env))
|
||||
|
||||
// Register routes
|
||||
e.GET("/", index.Handler)
|
||||
|
||||
Reference in New Issue
Block a user