Documentation ¶
Index ¶
- Constants
- Variables
- func Duplicated(v []string) bool
- func FromJsonBody[T Validable](r io.ReadCloser) (T, error)
- func FromUrlParams[T Parseable[T]](r *http.Request, name string) (T, error)
- func FromUrlQuery[T Parseable[T]](r *http.Request, name string, fallback T) (T, error)
- func HandlerFunc(f ApiFunction) http.HandlerFunc
- func MakeHttpError(err error) error
- func MakeServiceError(err error) error
- func WithInterval(i IntervalParams, column string) func(db *gorm.DB) *gorm.DB
- func WithMaximumBodySize(n int64) func(http.Handler) http.Handler
- func WithPagination(p PaginationParams) func(db *gorm.DB) *gorm.DB
- func WriteJson(w http.ResponseWriter, statusCode int, v any) error
- type ApiError
- type ApiFunction
- type IntervalParams
- type PaginatedResponse
- type PaginationMetadata
- type PaginationParams
- type Parseable
- type Validable
Constants ¶
View Source
const ( MaxUploadSize = 2 * (1 << 20) // 2MB DefaultBodySize = 1 << 18 // 256KB )
Variables ¶
Functions ¶
func Duplicated ¶
func FromJsonBody ¶
func FromJsonBody[T Validable](r io.ReadCloser) (T, error)
func FromUrlQuery ¶
func HandlerFunc ¶
func HandlerFunc(f ApiFunction) http.HandlerFunc
func MakeHttpError ¶
func MakeServiceError ¶
func WithInterval ¶
func WithPagination ¶
func WithPagination(p PaginationParams) func(db *gorm.DB) *gorm.DB
Types ¶
type ApiError ¶
type ApiError struct { Message string `json:"message"` // contains filtered or unexported fields }
ApiError represents the http error returned by the REST service. Implements error interface.
type ApiFunction ¶
type ApiFunction func(http.ResponseWriter, *http.Request) error
type PaginatedResponse ¶
type PaginatedResponse struct { Data any `json:"data"` Metadata PaginationMetadata `json:"metadata"` }
func MakePaginatedResponse ¶
func MakePaginatedResponse(v any, count int64, p PaginationParams) *PaginatedResponse
type PaginationMetadata ¶
type PaginationParams ¶
Click to show internal directories.
Click to hide internal directories.