encoding

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: MIT Imports: 2 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

Jump to

Keyboard shortcuts

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