Documentation
¶
Overview ¶
Package respond provides HTTP response helpers for HTMX-first applications.
It renders templ components or JSON payloads via Echo. Use respond.HTML for templ components and respond.JSON for API responses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTML ¶
HTML renders a templ component with the given status code.
The component is rendered into a buffer first: if rendering fails, no status or body has been committed, so the returned error reaches Echo's error handler and a proper error page can be sent. (Writing directly to the response would leave a committed 2xx with a truncated body.)
func ParsePagination ¶
ParsePagination reads page and size query params from the request. It defaults page to 1 and clamps size to [1, 100].
Types ¶
type Page ¶
type Page struct {
Number int `json:"number"`
Size int `json:"size"`
Total int `json:"total"`
TotalPages int `json:"total_pages"`
HasNext bool `json:"has_next"`
HasPrev bool `json:"has_prev"`
}
Page holds pagination metadata.
type PagedResponse ¶
PagedResponse wraps a slice of items with pagination metadata.