Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultMaxAllowedLimit determines the maximum value that can take limit when decode. DefaultMaxAllowedLimit = 100 // DefaultLimit default value that take limit when not limit param present in query params. DefaultLimit = 10 // DefaultOffset default value that take offset when not offset param present in query params. DefaultOffset = 0 )
Variables ¶
View Source
var ( // ErrInvalidOffsetValueNotANumber expected error when fails parsing the offset value to int. ErrInvalidOffsetValueNotANumber = errors.New("invalid offset value, must be a number") // ErrInvalidOffsetValueLessThanZero expected error when offset value is less than zero. ErrInvalidOffsetValueLessThanZero = errors.New("invalid offset value, must be greater than zero") // ErrInvalidLimitValueNotANumber expected error when fails parse limit value to int ErrInvalidLimitValueNotANumber = errors.New("invalid limit value, must be a number") // ErrInvalidLimitValueLessThanZero expected error when limit value is less than zero. ErrInvalidLimitValueLessThanZero = errors.New("invalid limit value, must be greater than zero") )
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder reads and decodes Paging values from url.Values.
func NewDecoder ¶
NewDecoder returns a new decoder that reads from params.
type Option ¶
type Option func(*Decoder)
Option allows to modify the defaults decode values.
func MaxAllowedLimit ¶
MaxAllowedLimit set the max allowed limit default.
type Paging ¶
type Paging struct { MaxAllowedLimit int `json:"max_allowed_limit"` Limit int `json:"limit"` Offset int64 `json:"offset"` Total int64 `json:"total,omitempty"` }
Paging struct allows to do pagination into a collection.
func (Paging) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
Click to show internal directories.
Click to hide internal directories.