diff --git a/pkg/routes/routes.go b/pkg/routes/routes.go index 7f6c77a86..37bc20e43 100644 --- a/pkg/routes/routes.go +++ b/pkg/routes/routes.go @@ -125,7 +125,6 @@ func NewEcho() *echo.Echo { }) handler.SetLoggingProvider(log.GetLogger()) handler.SetMaxItemsPerPage(config.ServiceMaxItemsPerPage.GetInt()) - handler.SetSessionFactory(db.NewSession) return e } diff --git a/pkg/web/handler/config.go b/pkg/web/handler/config.go index 85ab90d09..549d5129a 100644 --- a/pkg/web/handler/config.go +++ b/pkg/web/handler/config.go @@ -19,7 +19,6 @@ package handler import ( "code.vikunja.io/api/pkg/web" "github.com/op/go-logging" - "xorm.io/xorm" ) // Config contains the config for the web handler @@ -27,7 +26,6 @@ type Config struct { AuthProvider *web.Auths LoggingProvider *logging.Logger MaxItemsPerPage int - SessionFactory func() *xorm.Session } var config *Config @@ -50,8 +48,3 @@ func SetLoggingProvider(logger *logging.Logger) { func SetMaxItemsPerPage(maxItemsPerPage int) { config.MaxItemsPerPage = maxItemsPerPage } - -// SetSessionFactory sets the session factory -func SetSessionFactory(sessionFactory func() *xorm.Session) { - config.SessionFactory = sessionFactory -} diff --git a/pkg/web/handler/create.go b/pkg/web/handler/create.go index 0ca1e47f5..341fc69d6 100644 --- a/pkg/web/handler/create.go +++ b/pkg/web/handler/create.go @@ -21,6 +21,8 @@ import ( "fmt" "net/http" + "code.vikunja.io/api/pkg/db" + "github.com/labstack/echo/v4" ) @@ -51,7 +53,7 @@ func (c *WebHandler) CreateWeb(ctx echo.Context) error { } // Create the db session - s := config.SessionFactory() + s := db.NewSession() defer func() { err = s.Close() if err != nil { diff --git a/pkg/web/handler/delete.go b/pkg/web/handler/delete.go index 7e4ce0373..c60b35cb5 100644 --- a/pkg/web/handler/delete.go +++ b/pkg/web/handler/delete.go @@ -21,6 +21,8 @@ import ( "fmt" "net/http" + "code.vikunja.io/api/pkg/db" + "github.com/labstack/echo/v4" ) @@ -51,7 +53,7 @@ func (c *WebHandler) DeleteWeb(ctx echo.Context) error { } // Create the db session - s := config.SessionFactory() + s := db.NewSession() defer func() { err = s.Close() if err != nil { diff --git a/pkg/web/handler/read_all.go b/pkg/web/handler/read_all.go index 0b1f3a6ca..0d57da912 100644 --- a/pkg/web/handler/read_all.go +++ b/pkg/web/handler/read_all.go @@ -23,6 +23,8 @@ import ( "net/http" "strconv" + "code.vikunja.io/api/pkg/db" + "github.com/labstack/echo/v4" ) @@ -84,7 +86,7 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error { } // Create the db session - s := config.SessionFactory() + s := db.NewSession() defer func() { err = s.Close() if err != nil { diff --git a/pkg/web/handler/read_one.go b/pkg/web/handler/read_one.go index 410b8498f..18cfccb1e 100644 --- a/pkg/web/handler/read_one.go +++ b/pkg/web/handler/read_one.go @@ -22,6 +22,8 @@ import ( "net/http" "strconv" + "code.vikunja.io/api/pkg/db" + "github.com/labstack/echo/v4" ) @@ -47,7 +49,7 @@ func (c *WebHandler) ReadOneWeb(ctx echo.Context) error { } // Create the db session - s := config.SessionFactory() + s := db.NewSession() defer func() { err = s.Close() if err != nil { diff --git a/pkg/web/handler/update.go b/pkg/web/handler/update.go index 0d41f7cbd..7d34fccd7 100644 --- a/pkg/web/handler/update.go +++ b/pkg/web/handler/update.go @@ -21,6 +21,8 @@ import ( "fmt" "net/http" + "code.vikunja.io/api/pkg/db" + "github.com/labstack/echo/v4" ) @@ -52,7 +54,7 @@ func (c *WebHandler) UpdateWeb(ctx echo.Context) error { } // Create the db session - s := config.SessionFactory() + s := db.NewSession() defer func() { err = s.Close() if err != nil {