form

package module
v0.0.0-...-b87209e Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package form provides HTTP form <> protobuf encoding/decoding.

Index

Constants

View Source
const (
	// Name is form codec name.
	Name = "form"
	// ContentType used by HTTP forms.
	ContentType = "application/x-www-form-urlencoded"
)

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.

Types

type Form

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

Form is used to encode/decode HTML form values as used in GET request URL query parameters or POST request bodies.

func NewFormCodec

func NewFormCodec() *Form

NewFormCodec will create a codec used to encode/decode HTML form values as used in GET request URL query parameters or POST request bodies.

func (Form) ContentTypes

func (c Form) ContentTypes() []string

ContentTypes returns the Content-Type which this marshaler is responsible for. The parameter describes the type which is being marshaled, which can sometimes affect the content type returned.

func (Form) Decode

func (c Form) Decode(data []byte, v any) error

Decode unmarshals a struct from HTTP form format into an object.

func (Form) Decodes

func (Form) Decodes(v any) bool

Decodes returns if this is able to decode the given type.

func (Form) Encode

func (c Form) Encode(v any) ([]byte, error)

Encode marshals an object into HTTP form format.

func (Form) EncodeValues

func (c Form) EncodeValues(msg interface{}) (url.Values, error)

EncodeValues encode a message into url values.

func (Form) Encodes

func (Form) Encodes(v any) bool

Encodes returns if this is able to encode the given type.

func (Form) Exts

func (c Form) Exts() []string

Exts is a list of file extensions this encoder supports. Since the form codec is only used for request marshaling, no file extensions are supported.

func (Form) NewDecoder

func (c Form) NewDecoder(r io.Reader) codecs.Decoder

NewDecoder returns a Decoder which reads byte sequence from "r".

func (Form) NewEncoder

func (c Form) NewEncoder(w io.Writer) codecs.Encoder

NewEncoder returns an Encoder which writes bytes sequence into "w".

func (Form) String

func (Form) String() string

Jump to

Keyboard shortcuts

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