mrparser

package
v0.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FactoryErrHttpRequestFileSizeMin = NewFactory(
		"errHttpRequestFileSizeMin", ErrorKindUser, "invalid file size, min size = {{ .value }}b")

	FactoryErrHttpRequestFileSizeMax = NewFactory(
		"errHttpRequestFileSizeMax", ErrorKindUser, "invalid file size, max size = {{ .value }}b")

	FactoryErrHttpRequestFileExtension = NewFactory(
		"errHttpRequestFileExtension", ErrorKindUser, "invalid file extension: {{ .value }}")

	FactoryErrHttpRequestFileTotalSizeMax = NewFactory(
		"errHttpRequestFileTotalSizeMax", ErrorKindUser, "invalid file total size, max total size = {{ .value }}b")

	FactoryErrHttpRequestFileContentType = NewFactory(
		"errHttpRequestFileContentType", ErrorKindUser, "the content type '{{ .value }}' does not match the detected type")

	FactoryErrHttpRequestFileUnsupportedType = NewFactory(
		"errHttpRequestFileUnsupportedType", ErrorKindUser, "unsupported file type '{{ .value }}'")

	FactoryErrHttpRequestImageWidthMax = NewFactory(
		"errHttpRequestImageWidthMax", ErrorKindUser, "invalid image width, max size = {{ .value }}px")

	FactoryErrHttpRequestImageHeightMax = NewFactory(
		"errHttpRequestImageHeightMax", ErrorKindUser, "invalid image height, max size = {{ .value }}px")
)

Functions

func WrapFileError added in v0.12.0

func WrapFileError(err error, name string) error

func WrapImageError added in v0.12.0

func WrapImageError(err error, name string) error

Types

type Bool added in v0.12.0

type Bool struct {
}

func NewBool added in v0.12.0

func NewBool() *Bool

func (*Bool) FilterNullableBool added in v0.12.0

func (p *Bool) FilterNullableBool(r *http.Request, key string) *bool

type DateTime added in v0.12.0

type DateTime struct {
}

func NewDateTime added in v0.12.0

func NewDateTime() *DateTime

func (*DateTime) FilterDateTime added in v0.12.0

func (p *DateTime) FilterDateTime(r *http.Request, key string) time.Time

type File added in v0.12.0

type File struct {
	// contains filtered or unexported fields
}

func NewFile added in v0.12.0

func NewFile(opts FileOptions) *File

func (*File) FormFile added in v0.12.0

func (p *File) FormFile(r *http.Request, key string) (mrtype.File, error)

FormFile - WARNING you don't forget to call result.Body.Close()

func (*File) FormFileContent added in v0.12.0

func (p *File) FormFileContent(r *http.Request, key string) (mrtype.FileContent, error)

FormFileContent - only for short files

func (*File) FormFiles added in v0.14.0

func (p *File) FormFiles(r *http.Request, key string) ([]mrtype.FileHeader, error)

type FileOptions added in v0.12.0

type FileOptions struct {
	AllowedExts             []string
	MinSize                 int64
	MaxSize                 int64
	MaxTotalSize            int64
	MaxFiles                int
	CheckRequestContentType bool
}

type Image added in v0.12.0

type Image struct {
	// contains filtered or unexported fields
}

func NewImage added in v0.12.0

func NewImage(opts ImageOptions) *Image

func (*Image) FormImage added in v0.12.0

func (p *Image) FormImage(r *http.Request, key string) (mrtype.Image, error)

FormImage - WARNING you don't forget to call result.Body.Close()

func (*Image) FormImageContent added in v0.12.0

func (p *Image) FormImageContent(r *http.Request, key string) (mrtype.ImageContent, error)

FormImageContent - only for short files

func (*Image) FormImages added in v0.14.0

func (p *Image) FormImages(r *http.Request, key string) ([]mrtype.ImageHeader, error)

type ImageOptions added in v0.12.0

type ImageOptions struct {
	File      FileOptions
	MaxWidth  int32
	MaxHeight int32
	CheckBody bool
}

type Int64 added in v0.12.0

type Int64 struct {
	// contains filtered or unexported fields
}

func NewInt64 added in v0.12.0

func NewInt64(pathFunc mrserver.RequestParserParamFunc) *Int64

func (*Int64) FilterInt64 added in v0.12.0

func (p *Int64) FilterInt64(r *http.Request, key string) int64

func (*Int64) FilterInt64List added in v0.12.0

func (p *Int64) FilterInt64List(r *http.Request, key string) []int64

func (*Int64) FilterRangeInt64 added in v0.12.0

func (p *Int64) FilterRangeInt64(r *http.Request, key string) mrtype.RangeInt64

func (*Int64) PathParamInt64 added in v0.12.0

func (p *Int64) PathParamInt64(r *http.Request, name string) int64

type ItemStatus

type ItemStatus struct {
}

func NewItemStatus

func NewItemStatus() *ItemStatus

func (*ItemStatus) FilterStatusList

func (p *ItemStatus) FilterStatusList(r *http.Request, key string) []mrenum.ItemStatus

type KeyInt32

type KeyInt32 struct {
	// contains filtered or unexported fields
}

func NewKeyInt32

func NewKeyInt32(pathFunc mrserver.RequestParserParamFunc) *KeyInt32

func (*KeyInt32) FilterKeyInt32

func (p *KeyInt32) FilterKeyInt32(r *http.Request, key string) mrtype.KeyInt32

func (*KeyInt32) FilterKeyInt32List

func (p *KeyInt32) FilterKeyInt32List(r *http.Request, key string) []mrtype.KeyInt32

func (*KeyInt32) PathKeyInt32

func (p *KeyInt32) PathKeyInt32(r *http.Request, name string) mrtype.KeyInt32

type ListPager added in v0.14.0

type ListPager struct {
	// contains filtered or unexported fields
}

func NewListPager added in v0.14.0

func NewListPager(opts ListPagerOptions) *ListPager

func (*ListPager) PageParams added in v0.14.0

func (p *ListPager) PageParams(r *http.Request) mrtype.PageParams

type ListPagerOptions added in v0.14.0

type ListPagerOptions struct {
	ParamNamePageIndex string
	ParamNamePageSize  string
	PageSizeMax        uint64
	PageSizeDefault    uint64
}

type ListSorter added in v0.14.0

type ListSorter struct {
	// contains filtered or unexported fields
}

func NewListSorter added in v0.14.0

func NewListSorter(opts ListSorterOptions) *ListSorter

func (*ListSorter) SortParams added in v0.14.0

func (p *ListSorter) SortParams(r *http.Request, sorter mrview.ListSorter) mrtype.SortParams

type ListSorterOptions added in v0.14.0

type ListSorterOptions struct {
	ParamNameSortField     string
	ParamNameSortDirection string
}

type Parser added in v0.14.0

func NewParser added in v0.14.0

func NewParser(
	p1 *Bool,
	p2 *DateTime,
	p3 *Int64,
	p4 *KeyInt32,
	p5 *ListSorter,
	p6 *ListPager,
	p7 *String,
	p8 *UUID,
	p9 *Validator,
	p10 *File,
	p11 *Image,
) *Parser

type String added in v0.12.0

type String struct {
	// contains filtered or unexported fields
}

func NewString added in v0.12.0

func NewString(pathFunc mrserver.RequestParserParamFunc) *String

func (*String) FilterString added in v0.12.0

func (p *String) FilterString(r *http.Request, key string) string

func (*String) PathParamString added in v0.12.0

func (p *String) PathParamString(r *http.Request, name string) string

func (*String) RawParamString added in v0.12.0

func (p *String) RawParamString(r *http.Request, key string) *string

RawParamString - returns nil if the param not found

type UUID

type UUID struct {
	// contains filtered or unexported fields
}

func NewUUID

func NewUUID(pathFunc mrserver.RequestParserParamFunc) *UUID

func (*UUID) FilterUUID

func (p *UUID) FilterUUID(r *http.Request, key string) uuid.UUID

func (*UUID) PathParamUUID

func (p *UUID) PathParamUUID(r *http.Request, name string) uuid.UUID

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator(
	decoder mrserver.RequestDecoder,
	validator mrview.Validator,
) *Validator

func (*Validator) Validate

func (p *Validator) Validate(r *http.Request, structPointer any) error

func (*Validator) ValidateContent added in v0.14.0

func (p *Validator) ValidateContent(ctx context.Context, content []byte, structPointer any) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL