binding

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(req *http.Request, value interface{}) error

Exec will bind the interface to the request.Body. The type of binding is dependent on the "Content-Type" for the request. If the type is "application/json" it will use "json.NewDecoder". If the type is "application/xml" it will use "xml.NewDecoder". The default binder is "https://github.com/monoculum/formam".

func Register

func Register(contentType string, fn Binder)

Register maps a request Content-Type (application/json) to a Binder.

func RegisterCustomDecorder

func RegisterCustomDecorder(fn CustomTypeDecoder, types []interface{}, fields []interface{})

RegisterCustomDecorder allows to define custom type decoders.

func RegisterTimeFormats

func RegisterTimeFormats(layouts ...string)

RegisterTimeFormats allows to add custom time layouts that the binder will be able to use for decoding.

Types

type Binder

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

Binder takes a request and binds it to an interface. If there is a problem it should return an error.

type CustomTypeDecoder

type CustomTypeDecoder func([]string) (interface{}, error)

CustomTypeDecoder converts a custom type from the request insto its exact type.

Jump to

Keyboard shortcuts

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