Mandanten, OAuth, Cleanup von der Main Methode.

This commit is contained in:
2025-08-20 16:08:58 +02:00
parent a6570d463a
commit 372dced0a1
16 changed files with 432 additions and 154 deletions

View File

@ -1,5 +1,12 @@
package utils
import (
"errors"
"strconv"
"github.com/gofiber/fiber/v2"
)
type OffsetPaginationError struct {
Page int
Pages int
@ -35,3 +42,27 @@ func (p *KeysetPaginationError) Error() string {
func NewKeysetPaginationError(key int, next int, previous int) error {
return &KeysetPaginationError{Key: key, NextKey: next, PreviousKey: previous}
}
func AddPaginationParams(c *fiber.Ctx) error {
err := c.Next()
if err != nil {
var offset *OffsetPaginationError
if errors.As(err, &offset) {
c.Append("X-Page", strconv.Itoa(offset.Page))
c.Append("X-Pages", strconv.Itoa(offset.Pages))
c.Append("X-Next-Page", strconv.Itoa(offset.NextPage))
c.Append("X-Last-Page", strconv.Itoa(offset.LastPage))
return nil
}
var keyset *KeysetPaginationError
if errors.As(err, &keyset) {
c.Append("X-Key", strconv.Itoa(keyset.Key))
c.Append("X-Previous-Key", strconv.Itoa(keyset.PreviousKey))
c.Append("X-Next-Key", strconv.Itoa(keyset.NextKey))
return nil
}
}
return err
}