chore(web): use config directly
(cherry picked from commit bcfd72c64545241b53fc8a69197cfc6a3f316d92)
This commit is contained in:
parent
d885b43328
commit
5fba4ed6ef
@ -58,7 +58,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.vikunja.io/api/pkg/config"
|
"code.vikunja.io/api/pkg/config"
|
||||||
"code.vikunja.io/api/pkg/db"
|
|
||||||
"code.vikunja.io/api/pkg/log"
|
"code.vikunja.io/api/pkg/log"
|
||||||
"code.vikunja.io/api/pkg/models"
|
"code.vikunja.io/api/pkg/models"
|
||||||
"code.vikunja.io/api/pkg/modules/auth"
|
"code.vikunja.io/api/pkg/modules/auth"
|
||||||
@ -124,7 +123,6 @@ func NewEcho() *echo.Echo {
|
|||||||
AuthObject: auth.GetAuthFromClaims,
|
AuthObject: auth.GetAuthFromClaims,
|
||||||
})
|
})
|
||||||
handler.SetLoggingProvider(log.GetLogger())
|
handler.SetLoggingProvider(log.GetLogger())
|
||||||
handler.SetMaxItemsPerPage(config.ServiceMaxItemsPerPage.GetInt())
|
|
||||||
|
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
AuthProvider *web.Auths
|
AuthProvider *web.Auths
|
||||||
LoggingProvider *logging.Logger
|
LoggingProvider *logging.Logger
|
||||||
MaxItemsPerPage int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var config *Config
|
var config *Config
|
||||||
@ -43,8 +42,3 @@ func SetAuthProvider(provider *web.Auths) {
|
|||||||
func SetLoggingProvider(logger *logging.Logger) {
|
func SetLoggingProvider(logger *logging.Logger) {
|
||||||
config.LoggingProvider = logger
|
config.LoggingProvider = logger
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMaxItemsPerPage sets the max number of items per page in the config
|
|
||||||
func SetMaxItemsPerPage(maxItemsPerPage int) {
|
|
||||||
config.MaxItemsPerPage = maxItemsPerPage
|
|
||||||
}
|
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
vconfig "code.vikunja.io/api/pkg/config"
|
||||||
"code.vikunja.io/api/pkg/db"
|
"code.vikunja.io/api/pkg/db"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
@ -76,13 +77,13 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
|
|||||||
}
|
}
|
||||||
// Set default page count
|
// Set default page count
|
||||||
if perPageNumber == 0 {
|
if perPageNumber == 0 {
|
||||||
perPageNumber = config.MaxItemsPerPage
|
perPageNumber = vconfig.ServiceMaxItemsPerPage.GetInt()
|
||||||
}
|
}
|
||||||
if perPageNumber < 1 {
|
if perPageNumber < 1 {
|
||||||
return echo.NewHTTPError(http.StatusBadRequest, "Per page amount cannot be negative.")
|
return echo.NewHTTPError(http.StatusBadRequest, "Per page amount cannot be negative.")
|
||||||
}
|
}
|
||||||
if perPageNumber > config.MaxItemsPerPage {
|
if perPageNumber > vconfig.ServiceMaxItemsPerPage.GetInt() {
|
||||||
perPageNumber = config.MaxItemsPerPage
|
perPageNumber = vconfig.ServiceMaxItemsPerPage.GetInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the db session
|
// Create the db session
|
||||||
|
Loading…
x
Reference in New Issue
Block a user