mrparser

package
v0.18.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHttpRequestFileSizeMin - invalid file size - min.
	ErrHttpRequestFileSizeMin = mrerr.NewProto(
		"errHttpRequestFileSizeMin", mrerr.ErrorKindUser, "invalid file size, min size = {{ .value }}b")

	// ErrHttpRequestFileSizeMax - invalid file size - max.
	ErrHttpRequestFileSizeMax = mrerr.NewProto(
		"errHttpRequestFileSizeMax", mrerr.ErrorKindUser, "invalid file size, max size = {{ .value }}b")

	// ErrHttpRequestFileExtension - invalid file extension.
	ErrHttpRequestFileExtension = mrerr.NewProto(
		"errHttpRequestFileExtension", mrerr.ErrorKindUser, "invalid file extension: {{ .value }}")

	// ErrHttpRequestFileTotalSizeMax - invalid file total size - max.
	ErrHttpRequestFileTotalSizeMax = mrerr.NewProto(
		"errHttpRequestFileTotalSizeMax", mrerr.ErrorKindUser, "invalid file total size, max total size = {{ .value }}b")

	// ErrHttpRequestFileContentType - the content type does not match the detected type.
	ErrHttpRequestFileContentType = mrerr.NewProto(
		"errHttpRequestFileContentType", mrerr.ErrorKindUser, "the content type '{{ .value }}' does not match the detected type")

	// ErrHttpRequestFileUnsupportedType - unsupported file type.
	ErrHttpRequestFileUnsupportedType = mrerr.NewProto(
		"errHttpRequestFileUnsupportedType", mrerr.ErrorKindUser, "unsupported file type '{{ .value }}'")

	// ErrHttpRequestImageWidthMax - invalid image width - max.
	ErrHttpRequestImageWidthMax = mrerr.NewProto(
		"errHttpRequestImageWidthMax", mrerr.ErrorKindUser, "invalid image width, max size = {{ .value }}px")

	// ErrHttpRequestImageHeightMax - invalid image height - max.
	ErrHttpRequestImageHeightMax = mrerr.NewProto(
		"errHttpRequestImageHeightMax", mrerr.ErrorKindUser, "invalid image height, max size = {{ .value }}px")
)

Functions

func WrapFileError added in v0.12.0

func WrapFileError(err error, name string) error

WrapFileError - comment func.

func WrapImageError added in v0.12.0

func WrapImageError(err error, name string) error

WrapImageError - comment func.

Types

type Bool added in v0.12.0

type Bool struct{}

Bool - comment struct.

func NewBool added in v0.12.0

func NewBool() *Bool

NewBool - создаёт объект Bool.

func (*Bool) FilterNullableBool added in v0.12.0

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

FilterNullableBool - comment method.

type DateTime added in v0.12.0

type DateTime struct{}

DateTime - comment struct.

func NewDateTime added in v0.12.0

func NewDateTime() *DateTime

NewDateTime - создаёт объект DateTime.

func (*DateTime) FilterDateTime added in v0.12.0

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

FilterDateTime - comment method.

type File added in v0.12.0

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

File - comment struct.

func NewFile added in v0.12.0

func NewFile(opts FileOptions) *File

NewFile - создаёт объект 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)

FormFiles - comment method.

type FileOptions added in v0.12.0

type FileOptions struct {
	AllowedMimeTypes        *mrlib.MimeTypeList
	MinSize                 int64
	MaxSize                 int64
	MaxTotalSize            int64
	MaxFiles                int
	CheckRequestContentType bool
}

FileOptions - опции для создания File.

type Image added in v0.12.0

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

Image - comment struct.

func NewImage added in v0.12.0

func NewImage(opts ImageOptions) *Image

NewImage - создаёт объект 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)

FormImages - comment method.

type ImageOptions added in v0.12.0

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

ImageOptions - опции для создания Image.

type Int64 added in v0.12.0

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

Int64 - comment struct.

func NewInt64 added in v0.12.0

func NewInt64(pathFunc mrserver.RequestParserParamFunc) *Int64

NewInt64 - создаёт объект Int64.

func (*Int64) FilterInt64 added in v0.12.0

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

FilterInt64 - comment method.

func (*Int64) FilterInt64List added in v0.12.0

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

FilterInt64List - comment method.

func (*Int64) FilterRangeInt64 added in v0.12.0

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

FilterRangeInt64 - comment method.

func (*Int64) PathParamInt64 added in v0.12.0

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

PathParamInt64 - comment method.

type ItemStatus

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

ItemStatus - comment struct.

func NewItemStatus

func NewItemStatus() *ItemStatus

NewItemStatus - создаёт объект ItemStatus.

func NewItemStatusWithDefault added in v0.14.2

func NewItemStatusWithDefault(items []mrenum.ItemStatus) *ItemStatus

NewItemStatusWithDefault - создаёт объект ItemStatus.

func (*ItemStatus) FilterStatusList

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

FilterStatusList - comment method.

type KeyInt32

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

KeyInt32 - comment struct.

func NewKeyInt32

func NewKeyInt32(pathFunc mrserver.RequestParserParamFunc) *KeyInt32

NewKeyInt32 - создаёт объект KeyInt32.

func (*KeyInt32) FilterKeyInt32

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

FilterKeyInt32 - comment method.

func (*KeyInt32) FilterKeyInt32List

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

FilterKeyInt32List - comment method.

func (*KeyInt32) PathKeyInt32

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

PathKeyInt32 - comment method.

type ListPager added in v0.14.0

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

ListPager - comment struct.

func NewListPager added in v0.14.0

func NewListPager(opts ListPagerOptions) *ListPager

NewListPager - создаёт объект ListPager.

func (*ListPager) PageParams added in v0.14.0

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

PageParams - comment method.

type ListPagerOptions added in v0.14.0

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

ListPagerOptions - опции для создания ListPager.

type ListSorter added in v0.14.0

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

ListSorter - comment struct.

func NewListSorter added in v0.14.0

func NewListSorter(opts ListSorterOptions) *ListSorter

NewListSorter - создаёт объект ListSorter.

func (*ListSorter) SortParams added in v0.14.0

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

SortParams - comment method.

type ListSorterOptions added in v0.14.0

type ListSorterOptions struct {
	ParamNameSortField     string
	ParamNameSortDirection string
}

ListSorterOptions - опции для создания ListSorter.

type Parser added in v0.14.0

Parser - comment struct.

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

NewParser - создаёт объект Parser.

type String added in v0.12.0

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

String - comment struct.

func NewString added in v0.12.0

func NewString(pathFunc mrserver.RequestParserParamFunc) *String

NewString - создаёт объект String.

func (*String) FilterString added in v0.12.0

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

FilterString - comment method.

func (*String) PathParamString added in v0.12.0

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

PathParamString - comment method.

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
}

UUID - comment struct.

func NewUUID

func NewUUID(pathFunc mrserver.RequestParserParamFunc) *UUID

NewUUID - создаёт объект UUID.

func (*UUID) FilterUUID

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

FilterUUID - comment method.

func (*UUID) PathParamUUID

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

PathParamUUID - comment method.

type Validator

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

Validator - comment struct.

func NewValidator

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

NewValidator - создаёт объект Validator.

func (*Validator) Validate

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

Validate - comment method.

func (*Validator) ValidateContent added in v0.14.0

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

ValidateContent - comment method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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