params

package
v0.0.0-...-e7b361f Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package params unifies access to httprouter, POST, PUT, GET, etc., parameters and automatically converts parameters from string to the destination type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// AfterParse is called after Parse executed successfully. It is useful for
	// operations that should occur after parsing, like validation.
	AfterParse func(dest interface{}) error
	// contains filtered or unexported fields
}

Parser parses httprouter, POST, PUT, GET, etc., parameters.

func NewParser

func NewParser(request *http.Request, params httprouter.Params) (*Parser, error)

NewParser returns a new Parser.

func (*Parser) Parse

func (p *Parser) Parse(dest interface{}) error

Parse takes a pointer to a struct, and for each struct field it tries to find a corresponding parameter, converts the parameter from string to the struct field’s type and writes it to the struct field. A struct field and parameter correspond when the parameter name matches the lowercased struct field name.

Jump to

Keyboard shortcuts

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