Changed page int64 to int since its all limit can handle
This commit is contained in:
parent
f7834b02a1
commit
23a3d14517
|
@ -147,7 +147,7 @@ handler.SetLoggingProvider(&log.Log)
|
|||
The `ReadAll`-method has a number of parameters:
|
||||
|
||||
```go
|
||||
ReadAll(auth Auth, search string, page int64, perPage int64) (result interface{}, resultCount int64, numberOfPages int64, err error)
|
||||
ReadAll(auth Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfPages int, err error)
|
||||
```
|
||||
|
||||
The third parameter contains the requested page, the fourth parameter contains the number of items per page.
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
type Config struct {
|
||||
AuthProvider *web.Auths
|
||||
LoggingProvider *logging.Logger
|
||||
MaxItemsPerPage int64
|
||||
MaxItemsPerPage int
|
||||
}
|
||||
|
||||
var config *Config
|
||||
|
|
|
@ -41,7 +41,7 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
|
|||
if page == "" {
|
||||
page = "1"
|
||||
}
|
||||
pageNumber, err := strconv.ParseInt(page, 10, 64)
|
||||
pageNumber, err := strconv.Atoi(page)
|
||||
if err != nil {
|
||||
config.LoggingProvider.Error(err.Error())
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Bad page requested.")
|
||||
|
@ -52,7 +52,7 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
|
|||
|
||||
// Items per page
|
||||
perPage := ctx.QueryParam("per_page")
|
||||
perPageNumber, err := strconv.ParseInt(perPage, 10, 64)
|
||||
perPageNumber, err := strconv.Atoi(perPage)
|
||||
if err != nil {
|
||||
config.LoggingProvider.Error(err.Error())
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Bad per page amount requested.")
|
||||
|
@ -76,8 +76,8 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
|
|||
return HandleHTTPError(err, ctx)
|
||||
}
|
||||
|
||||
ctx.Response().Header().Set("x-pagination-total-pages", strconv.FormatInt(numberOfPages, 10))
|
||||
ctx.Response().Header().Set("x-pagination-result-count", strconv.FormatInt(resultCount, 10))
|
||||
ctx.Response().Header().Set("x-pagination-total-pages", strconv.FormatInt(int64(numberOfPages), 10))
|
||||
ctx.Response().Header().Set("x-pagination-result-count", strconv.FormatInt(int64(resultCount), 10))
|
||||
ctx.Response().Header().Set("Access-Control-Expose-Headers", "x-pagination-total-pages, x-pagination-result-count")
|
||||
|
||||
return ctx.JSON(http.StatusOK, result)
|
||||
|
|
2
web.go
2
web.go
|
@ -31,7 +31,7 @@ type Rights interface {
|
|||
type CRUDable interface {
|
||||
Create(Auth) error
|
||||
ReadOne() error
|
||||
ReadAll(auth Auth, search string, page int64, perPage int64) (result interface{}, resultCount int64, numberOfPages int64, err error)
|
||||
ReadAll(auth Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfPages int, err error)
|
||||
Update() error
|
||||
Delete() error
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue