Documentation
¶
Index ¶
- Constants
- func BadRequestResponse(w http.ResponseWriter, r *http.Request, errors map[string]string)
- func ErrorResponse(w http.ResponseWriter, r *http.Request, status int, message any)
- func MethodNotAllowedResponse(w http.ResponseWriter, r *http.Request)
- func NotFoundResponse(w http.ResponseWriter, r *http.Request)
- func PageSizeToLimitOffset(page, size int) (int, int)
- func ReadBody(w http.ResponseWriter, r *http.Request) io.Reader
- func ReadInt(qs url.Values, key string, defaultValue int, v *validator.Validator) int
- func ReadJSON(r io.Reader, dst any, strict bool) error
- func ServerErrorResponse(w http.ResponseWriter, r *http.Request, err error)
- func WriteJSON(w http.ResponseWriter, status int, src any, header http.Header) error
Constants ¶
View Source
const MaxBytes = 1024 * 1024
Limit the size of the request body to 1MB.
Variables ¶
This section is empty.
Functions ¶
func BadRequestResponse ¶
func ErrorResponse ¶
func MethodNotAllowedResponse ¶
func MethodNotAllowedResponse(w http.ResponseWriter, r *http.Request)
func NotFoundResponse ¶
func NotFoundResponse(w http.ResponseWriter, r *http.Request)
func PageSizeToLimitOffset ¶
Convert user-friendly "page/size" pagination to DB-friendly "limit/offset".
func ServerErrorResponse ¶
func ServerErrorResponse(w http.ResponseWriter, r *http.Request, err error)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.