Documentation ¶
Index ¶
- func Response(c *fiber.Ctx, code int, message string, data any) error
- func StatusBadRequest(c *fiber.Ctx, data any) error
- func StatusInternalServerError(c *fiber.Ctx) error
- func StatusNotFound(c *fiber.Ctx) error
- func StatusOK(c *fiber.Ctx, message string, data any) error
- func StatusUnauthorized(c *fiber.Ctx, data any) error
- type HTTPResponse
- type PaginationQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Response ¶
Response is a takes in context object, an HTTP status code, a message string and some data.
func StatusInternalServerError ¶
func StatusInternalServerError(c *fiber.Ctx) error
StatusInternalServerError is ...
func StatusUnauthorized ¶
StatusUnauthorized is ...
Types ¶
type HTTPResponse ¶
type HTTPResponse struct { Success bool `json:"success"` Message string `json:"message"` Data any `json:"data,omitempty"` }
HTTPResponse represents response body of API
type PaginationQuery ¶
type PaginationQuery struct { Limit int32 `json:"limit" form:"limit"` Offset int32 `json:"offset" form:"offset"` SortBy string `json:"sort_by" form:"sort_by"` // Corrected typo in form tag. }
PaginationQuery represents pagination parameters.
func GetPaginationFromCtx ¶
func GetPaginationFromCtx(c *fiber.Ctx) *PaginationQuery
GetPaginationFromCtx creates a PaginationQuery from the fiber context.
func (*PaginationQuery) GetQueryString ¶
func (p *PaginationQuery) GetQueryString() string
GetQueryString constructs a query string with the pagination parameters.
func (*PaginationQuery) GetSelectPage ¶
func (p *PaginationQuery) GetSelectPage() int32
GetSelectPage calculates the current page based on offset and limit.
func (*PaginationQuery) GetTotalPages ¶
func (p *PaginationQuery) GetTotalPages(totalRecords int32) int32
GetTotalPages calculates the total number of pages based on total records.
Click to show internal directories.
Click to hide internal directories.