form

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package form provides decoding functions for an http request forms (query, url-encoded, multipart). The decoding consists of both unmarshalling of the query and validation. Validation consist of builtin tag options like required but also by self validation of your destination interface. Customs types can be used for unmarshalling if they implements encoding.TextUnmarshaller, encoding.BinaryUnmarshaler, StringSetter.

Index

Constants

This section is empty.

Variables

View Source
var (
	TextUnmarshalerType   = reflect.TypeOf(new(encoding.TextUnmarshaler)).Elem()
	BinaryUnmarshalerType = reflect.TypeOf(new(encoding.BinaryUnmarshaler)).Elem()
	StringSetterType      = reflect.TypeOf(new(StringSetter)).Elem()
)

Types implementing TexTUnmarshaler and StringSetter used on unmarshalling

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	BoolStrictMode bool
	Input          *problem.Input
	// contains filtered or unexported fields
}

Decoder handles unmarshalling and validation of its request's query

func NewDecoder

func NewDecoder(r *http.Request) *Decoder

NewDecoder return a pointer to a new decoder

func (*Decoder) Decode

func (d *Decoder) Decode(v interface{}) error

Decode input data from its request and stores it onto i.

type IntList

type IntList []int

IntList implements encoding.TextUnmarshaler in order to extract query of form ?key=1,2,3,4 onto an int slice

func (*IntList) UnmarshalText

func (l *IntList) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type StringList

type StringList []string

StringList implements encoding.TextUnmarshaler in order to extract query of form ?key=foo,bar onto a string slice

func (*StringList) UnmarshalText

func (l *StringList) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type StringSetter

type StringSetter interface {
	Set(string) error
}

StringSetter see flag.Value

Jump to

Keyboard shortcuts

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