request

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidContentTypeField = "Content-Type"
)

Variables

View Source
var (
	ErrCodeNilRequest         string
	ErrCodeInvalidContentType string
	ErrCodeInvalidBodyType    string
)
View Source
var (
	ErrNilDecoder         = errors.New("decoder is nil")
	ErrNilRequest         = errors.New("request cannot be nil")
	ErrInvalidContentType = errors.New("invalid content type, expected application/json")
	ErrInvalidBodyType    = errors.New("invalid body type, expected struct")
	ErrInvalidInstance    = errors.New("invalid instance provided to create a reader")
)

Functions

func CheckContentType added in v0.12.2

func CheckContentType(r *http.Request) bool

CheckContentType checks if the content type is JSON

Parameters:

  • r: The HTTP request

Returns:

  • bool: True if the content type is JSON, false otherwise

func ToReader added in v0.12.3

func ToReader(any interface{}) (io.Reader, error)

ToReader converts an interface{} to an io.Reader

Parameters:

  • any: The interface{} to convert (can be io.Reader, string, or []byte)

Returns:

- io.Reader: The converted io.Reader - error: Error if the conversion fails

Types

type Decoder

type Decoder interface {
	Decode(
		body interface{},
		dest interface{},
	) error
	DecodeReader(
		reader io.Reader,
		dest interface{},
	) error
	DecodeRequest(
		r *http.Request,
		dest interface{},
	) error
}

Decoder interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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