backend api, swagger, tooling, frontend skeleton
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type paginatedResponse struct {
|
||||
Items any `json:"items"`
|
||||
Meta struct {
|
||||
Total int `json:"total"`
|
||||
Page int `json:"page"`
|
||||
Limit int `json:"limit"`
|
||||
} `json:"meta"`
|
||||
}
|
||||
|
||||
func respondPaginated(c *gin.Context, items any, total int, page int, limit int) {
|
||||
var resp paginatedResponse
|
||||
resp.Items = items
|
||||
resp.Meta.Total = total
|
||||
resp.Meta.Page = page
|
||||
resp.Meta.Limit = limit
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
Reference in New Issue
Block a user