Documentation ¶
Index ¶
- Constants
- func BindBody(c echo.Context, i interface{}) error
- func ReadJsonBodyCopy(r *http.Request, i interface{}) error
- type ApiError
- func NewApiError(status int, message string, data any) *ApiError
- func NewBadRequestError(message string, data any) *ApiError
- func NewForbiddenError(message string, data any) *ApiError
- func NewNotFoundError(message string, data any) *ApiError
- func NewUnauthorizedError(message string, data any) *ApiError
- type UploadedFile
Constants ¶
const DefaultMaxMemory = 32 << 20 // 32mb
DefaultMaxMemory defines the default max memory bytes that will be used when parsing a form request body.
Variables ¶
This section is empty.
Functions ¶
func BindBody ¶
func BindBody(c echo.Context, i interface{}) error
BindBody binds request body content to i.
This is similar to `echo.BindBody()`, but for JSON requests uses custom json reader that **copies** the request body, allowing multiple reads.
func ReadJsonBodyCopy ¶
ReadJsonBodyCopy reads the request body into i by creating a copy of `r.Body` to allow multiple reads.
Types ¶
type ApiError ¶
type ApiError struct { Code int `json:"code"` Message string `json:"message"` Data map[string]any `json:"data"` // contains filtered or unexported fields }
ApiError defines the properties for a basic api error response.
func NewApiError ¶
NewApiError creates and returns new normalized `ApiError` instance.
func NewBadRequestError ¶
NewBadRequestError creates and returns 400 `ApiError`.
func NewForbiddenError ¶
NewForbiddenError creates and returns 403 `ApiError`.
func NewNotFoundError ¶
NewNotFoundError creates and returns 404 `ApiError`.
func NewUnauthorizedError ¶
NewUnauthorizedError creates and returns 401 `ApiError`.
type UploadedFile ¶
type UploadedFile struct {
// contains filtered or unexported fields
}
UploadedFile defines a single multipart uploaded file instance.
func FindUploadedFiles ¶
func FindUploadedFiles(r *http.Request, key string) ([]*UploadedFile, error)
FindUploadedFiles extracts all form files of `key` from a http request and returns a slice with `UploadedFile` instances (if any).
func (*UploadedFile) Bytes ¶
func (f *UploadedFile) Bytes() []byte
Bytes returns a slice with the file content.
func (*UploadedFile) Header ¶
func (f *UploadedFile) Header() *multipart.FileHeader
Header returns the file header that comes with the multipart request.
func (*UploadedFile) Name ¶
func (f *UploadedFile) Name() string
Name returns an assigned unique name to the uploaded file.