bodyparser

package
v1.9.9 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding string
const (
	JSON Binding = "json"
)

type BodyParser

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

BodyParser object

func (*BodyParser) GetRequest

func (b *BodyParser) GetRequest() *http.Request

Gets the corresponding request context

func (*BodyParser) New

func (b *BodyParser) New(r *http.Request)

Creates a new bodyparser object

func (*BodyParser) Parse

func (b *BodyParser) Parse(dest interface{}, ct Binding) error

Parse request body to given binding, parses it into dest, so dest should be a pointer struct. Currently only parsing JSON body's is supported

Soon we'll add support for multiple bindings

type BodyParserI

type BodyParserI interface {
	// a parser to support multiple content type parsing
	Parse(dest interface{}, ct Binding) error
	// gets the corresponding request context
	GetRequest() *http.Request
	// function that sets request object into the bodyparser struct field 'req'
	New(r *http.Request)
}

the methods a body parser has to implement

var DefaultBodyParser BodyParserI = &BodyParser{}

the default bodyparser

Jump to

Keyboard shortcuts

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