chore(web): directly use new db session
(cherry picked from commit 499f66b7ae4d79e4b69c90caa618f25a18173925)
This commit is contained in:
parent
459c8daed6
commit
d885b43328
@ -125,7 +125,6 @@ func NewEcho() *echo.Echo {
|
|||||||
})
|
})
|
||||||
handler.SetLoggingProvider(log.GetLogger())
|
handler.SetLoggingProvider(log.GetLogger())
|
||||||
handler.SetMaxItemsPerPage(config.ServiceMaxItemsPerPage.GetInt())
|
handler.SetMaxItemsPerPage(config.ServiceMaxItemsPerPage.GetInt())
|
||||||
handler.SetSessionFactory(db.NewSession)
|
|
||||||
|
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"code.vikunja.io/api/pkg/web"
|
"code.vikunja.io/api/pkg/web"
|
||||||
"github.com/op/go-logging"
|
"github.com/op/go-logging"
|
||||||
"xorm.io/xorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config contains the config for the web handler
|
// Config contains the config for the web handler
|
||||||
@ -27,7 +26,6 @@ type Config struct {
|
|||||||
AuthProvider *web.Auths
|
AuthProvider *web.Auths
|
||||||
LoggingProvider *logging.Logger
|
LoggingProvider *logging.Logger
|
||||||
MaxItemsPerPage int
|
MaxItemsPerPage int
|
||||||
SessionFactory func() *xorm.Session
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var config *Config
|
var config *Config
|
||||||
@ -50,8 +48,3 @@ func SetLoggingProvider(logger *logging.Logger) {
|
|||||||
func SetMaxItemsPerPage(maxItemsPerPage int) {
|
func SetMaxItemsPerPage(maxItemsPerPage int) {
|
||||||
config.MaxItemsPerPage = maxItemsPerPage
|
config.MaxItemsPerPage = maxItemsPerPage
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSessionFactory sets the session factory
|
|
||||||
func SetSessionFactory(sessionFactory func() *xorm.Session) {
|
|
||||||
config.SessionFactory = sessionFactory
|
|
||||||
}
|
|
||||||
|
@ -21,6 +21,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"code.vikunja.io/api/pkg/db"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ func (c *WebHandler) CreateWeb(ctx echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the db session
|
// Create the db session
|
||||||
s := config.SessionFactory()
|
s := db.NewSession()
|
||||||
defer func() {
|
defer func() {
|
||||||
err = s.Close()
|
err = s.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -21,6 +21,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"code.vikunja.io/api/pkg/db"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ func (c *WebHandler) DeleteWeb(ctx echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the db session
|
// Create the db session
|
||||||
s := config.SessionFactory()
|
s := db.NewSession()
|
||||||
defer func() {
|
defer func() {
|
||||||
err = s.Close()
|
err = s.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -23,6 +23,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"code.vikunja.io/api/pkg/db"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -84,7 +86,7 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the db session
|
// Create the db session
|
||||||
s := config.SessionFactory()
|
s := db.NewSession()
|
||||||
defer func() {
|
defer func() {
|
||||||
err = s.Close()
|
err = s.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -22,6 +22,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"code.vikunja.io/api/pkg/db"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,7 +49,7 @@ func (c *WebHandler) ReadOneWeb(ctx echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the db session
|
// Create the db session
|
||||||
s := config.SessionFactory()
|
s := db.NewSession()
|
||||||
defer func() {
|
defer func() {
|
||||||
err = s.Close()
|
err = s.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -21,6 +21,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"code.vikunja.io/api/pkg/db"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ func (c *WebHandler) UpdateWeb(ctx echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the db session
|
// Create the db session
|
||||||
s := config.SessionFactory()
|
s := db.NewSession()
|
||||||
defer func() {
|
defer func() {
|
||||||
err = s.Close()
|
err = s.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user