Documentation ¶
Index ¶
- Variables
- func RemovePrefix(prefix string, mask *fieldmaskpb.FieldMask) *fieldmaskpb.FieldMask
- type FieldUpdater
- type FieldUpdaterOption
- func WithResetMask(resetMask *fieldmaskpb.FieldMask) FieldUpdaterOption
- func WithResetPaths(paths ...string) FieldUpdaterOption
- func WithUpdateMask(updateMask *fieldmaskpb.FieldMask) FieldUpdaterOption
- func WithUpdateMaskFieldName(name string) FieldUpdaterOption
- func WithWritableFields(writableFields *fieldmaskpb.FieldMask) FieldUpdaterOption
- type ResponseFilter
- type ResponseFilterOption
Constants ¶
This section is empty.
Variables ¶
var DefaultFieldUpdateOptions = []FieldUpdaterOption{ WithUpdateMaskFieldName("update_mask"), }
Functions ¶
func RemovePrefix ¶
func RemovePrefix(prefix string, mask *fieldmaskpb.FieldMask) *fieldmaskpb.FieldMask
Types ¶
type FieldUpdater ¶
type FieldUpdater struct {
// contains filtered or unexported fields
}
func NewFieldUpdater ¶
func NewFieldUpdater(opts ...FieldUpdaterOption) *FieldUpdater
func (*FieldUpdater) Merge ¶
func (f *FieldUpdater) Merge(dst, src proto.Message)
Merge copies the values in src into dst based on the configured field masks.
type FieldUpdaterOption ¶
type FieldUpdaterOption func(*FieldUpdater)
func WithResetMask ¶
func WithResetMask(resetMask *fieldmaskpb.FieldMask) FieldUpdaterOption
WithResetMask configures the FieldUpdater to clear the values mentioned in the mask.
func WithResetPaths ¶
func WithResetPaths(paths ...string) FieldUpdaterOption
WithResetPaths is like WithResetMask but accepts paths.
func WithUpdateMask ¶
func WithUpdateMask(updateMask *fieldmaskpb.FieldMask) FieldUpdaterOption
WithUpdateMask configures the FieldUpdater to only apply values for the mentioned fields. A nil updateMask represents all writable fields.
func WithUpdateMaskFieldName ¶
func WithUpdateMaskFieldName(name string) FieldUpdaterOption
WithUpdateMaskFieldName configures the name of the field that holds the update mask. Will be used when constructing error messages. Defaults to "update_mask".
func WithWritableFields ¶
func WithWritableFields(writableFields *fieldmaskpb.FieldMask) FieldUpdaterOption
WithWritableFields configures the FieldUpdater to validate that no non-writable fields are being written. A nil writableFields means all fields are writable.
type ResponseFilter ¶
type ResponseFilter struct {
// contains filtered or unexported fields
}
ResponseFilter provides utilities for applying FieldMasks to responses.
func NewResponseFilter ¶
func NewResponseFilter(opts ...ResponseFilterOption) *ResponseFilter
NewResponseFilter creates a new ResponseFilter with the given options applied.
func (*ResponseFilter) Filter ¶
func (r *ResponseFilter) Filter(msg proto.Message)
Filter resets all fields in msg that are not requested via the WithFieldMask option. If no field mask is configured, will not modify the msg. This changes the original message.
func (*ResponseFilter) FilterClone ¶
func (r *ResponseFilter) FilterClone(msg proto.Message) proto.Message
FilterClone is like Filter but clones and returns a new msg instead of modifying the original.
type ResponseFilterOption ¶
type ResponseFilterOption func(*ResponseFilter)
func WithFieldMask ¶
func WithFieldMask(fm *fieldmaskpb.FieldMask) ResponseFilterOption
func WithFieldMaskPaths ¶
func WithFieldMaskPaths(paths ...string) ResponseFilterOption