decoder

package
v0.0.0-...-608150b Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package decoder provides request decoding functionality for the context. Feed decoder interface implementation into the context object when you reset it, and it will be used to decode request data.

Typical usage:

dec := decoder.JSON
ctx.Reset(..., dec, ...)
// ...
if err := ctx.Decode(r, &data); err != nil {
    ctx.BadRequestResponse(nil, err.Error())
}

Index

Constants

This section is empty.

Variables

View Source
var (
	// JSON decoder treats request body as json.
	JSON = Func(decodeJSON)
)

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	Decode(*http.Request, interface{}) error
}

Decoder interface that decodes http request into arbitrary data.

type Func

type Func func(*http.Request, interface{}) error

Func is the function that implements Decoder interface by calling itself on Decode method.

func (Func) Decode

func (f Func) Decode(r *http.Request, data interface{}) error

Decode method implements Decoder interface by calling the function itself.

Jump to

Keyboard shortcuts

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