fieldmask

package
v0.0.0-...-22f70c5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryParamFieldMask = "fields"
)

Variables

View Source
var (
	ErrFieldMaskMissing = errors.New("field mask query param is not set")
	ErrFieldMaskEmpty   = errors.New("field mask is empty")
	ErrInvalidFieldMask = errors.New("field mask is invalid: ")

	FieldMaskRe = regexp.MustCompile(`^(\*|(\w+\.)*\*?|\w+(\.\w+)*\*?)$`)
)

Functions

func FieldMasksForType

func FieldMasksForType(item any, parent string) map[string]struct{}

FieldMasksForType returns a map of JSON field names for the given struct type.

func ParseFieldMask

func ParseFieldMask(fieldMask string) ([]string, error)

ParseFieldMask parses and validates the field mask from the given string.

func ParseFieldMaskRequest

func ParseFieldMaskRequest(r *http.Request) ([]string, error)

ParseFieldMaskRequest parses and validates the field mask from the HTTP request's query parameters. It returns a slice of field masks or an error if the field mask is missing, empty, or invalid.

Types

type InvalidFieldMaskError

type InvalidFieldMaskError struct {
	FieldMask []string
}

func NewInvalidFieldMaskError

func NewInvalidFieldMaskError(fieldMask []string) *InvalidFieldMaskError

func (*InvalidFieldMaskError) Error

func (e *InvalidFieldMaskError) Error() string

Jump to

Keyboard shortcuts

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