form

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeValues

func DecodeValues(msg proto.Message, values url.Values) error

DecodeValues decode url value into proto message.

func EncodeField

func EncodeField(fieldDescriptor protoreflect.FieldDescriptor, value protoreflect.Value) (string, error)

EncodeField encode proto message filed

func EncodeFieldMask

func EncodeFieldMask(m protoreflect.Message) (query string)

EncodeFieldMask return field mask name=paths

func EncodeValues

func EncodeValues(msg proto.Message) (url.Values, error)

EncodeValues encode a message into url values.

Types

type Codec

type Codec struct {
	Encoder  *form.Encoder
	Decoder  *form.Decoder
	TagName  string
	UseProto bool
}

func New

func New(tagName string) *Codec

New returns a new Codec, default tag name is "json", proto use protoJSON tag

func (*Codec) ContentType

func (*Codec) ContentType(_ interface{}) string

func (*Codec) Decode

func (c *Codec) Decode(vs url.Values, v any) error

func (*Codec) EnableProto added in v0.0.3

func (c *Codec) EnableProto() *Codec

EnableProto enable use proto field

func (*Codec) Encode

func (c *Codec) Encode(v any) (url.Values, error)

func (*Codec) EncodeURL

func (c *Codec) EncodeURL(pathTemplate string, v any, needQuery bool) string

EncodeURL encode msg to url path. pathTemplate is a template of url path like http://helloworld.dev/{name}/sub/{sub.name},

func (*Codec) Marshal

func (c *Codec) Marshal(v any) ([]byte, error)

func (*Codec) NewDecoder

func (c *Codec) NewDecoder(r io.Reader) codec.Decoder

func (*Codec) NewEncoder

func (c *Codec) NewEncoder(w io.Writer) codec.Encoder

func (*Codec) Unmarshal

func (c *Codec) Unmarshal(data []byte, v any) error

type MultipartCodec

type MultipartCodec struct {
	*Codec
}

func (*MultipartCodec) ContentType

func (*MultipartCodec) ContentType(_ interface{}) string

type QueryCodec

type QueryCodec struct {
	*Codec
}

func (*QueryCodec) ContentType

func (*QueryCodec) ContentType(_ interface{}) string

type UriCodec

type UriCodec struct {
	*Codec
}

func (*UriCodec) ContentType

func (*UriCodec) ContentType(_ interface{}) string

Jump to

Keyboard shortcuts

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