encoding

package
v0.0.0-...-44fb183 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDecoder

func RegisterDecoder[T DecoderConstraint](dec T, mime string, aliases ...string)

RegisterDecoder registers a request decoder for a given media type.

func RegisterEncoder

func RegisterEncoder[T EncoderConstraint](enc T, mime string, aliases ...string)

RegisterEncoder registers a response encoder on a given media type.

Types

type ContextMarshaler

type ContextMarshaler = func(ctx context.Context, v any) ([]byte, error)

type ContextUnmarshaler

type ContextUnmarshaler = func(ctx context.Context, data []byte, v any) error

type DecoderConstraint

type DecoderConstraint interface {
	Unmarshaler | ContextUnmarshaler | RequestParser
}

type EncoderConstraint

type EncoderConstraint interface {
	Marshaler | ContextMarshaler | ResponseEncoder
}

type Marshaler

type Marshaler = func(v any) ([]byte, error)

type RequestParser

type RequestParser = func(ctx *fasthttp.RequestCtx, v any) error

func GetDecoder

func GetDecoder(mime string) RequestParser

GetDecoder returns the request decoder for a given media type.

type ResponseEncoder

type ResponseEncoder = func(ctx *fasthttp.RequestCtx, v any) error

func GetEncoder

func GetEncoder(mime string) ResponseEncoder

GetEncoder returns the response encoder for a given media type.

type Unmarshaler

type Unmarshaler = func(data []byte, v any) error

Directories

Path Synopsis
Package form provides decoding of form data.
Package form provides decoding of form data.
Package json provides encoding and decoding of JSON data.
Package json provides encoding and decoding of JSON data.
Package msgpack provides encoding and decoding of MessagePack data.
Package msgpack provides encoding and decoding of MessagePack data.
Package protobuf provides encoding and decoding of Protocol Buffers data.
Package protobuf provides encoding and decoding of Protocol Buffers data.
Package text provides encoding and decoding of plain text data.
Package text provides encoding and decoding of plain text data.
Package toml provides encoding and decoding of TOML data.
Package toml provides encoding and decoding of TOML data.
Package xml provides encoding and decoding of XML data.
Package xml provides encoding and decoding of XML data.
Package yaml provides encoding and decoding of YAML data.
Package yaml provides encoding and decoding of YAML data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳