route

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: MIT Imports: 7 Imported by: 0

README

chi-route

A small helper package for build go-chi routes, and parsing query strings.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNonPointer = errors.New("non-pointer passed")
)

Functions

func CreateQuery

func CreateQuery(params interface{}, s setter) error

CreateQuery will iterate through the given struct or pointer to a struct, looking for fields tagged with `query`. For each tagged field that is not the zero value s.Set() is called with the string version of that field's value.

func Join

func Join(sep string, elements ...interface{}) string

func ParseQuery

func ParseQuery(r getter, params interface{}) error

ParseQuery will fill out the params based on the query tag.

func Pattern

func Pattern(elements ...interface{}) string

Pattern builds route strings that match the chi URL pattern

Types

type ErrQueryParseUnsupportedType

type ErrQueryParseUnsupportedType struct {
	Type reflect.Type
}

ErrQueryParseUnsupportedType is returned when a query tag is applied to an unsupported type

func (ErrQueryParseUnsupportedType) Error

type Token

type Token string

Token represents a go-chi token in a url

func (Token) AsInt32

func (tok Token) AsInt32(r *http.Request) (int32, error)

func (Token) AsInt64

func (tok Token) AsInt64(r *http.Request) (int64, error)

func (Token) Get

func (tok Token) Get(r *http.Request) string

func (Token) String

func (tok Token) String() string

func (Token) Token

func (tok Token) Token() string

Directories

Path Synopsis
_examples
blog
REST ==== This example demonstrates a HTTP REST web service with some fixture data.
REST ==== This example demonstrates a HTTP REST web service with some fixture data.

Jump to

Keyboard shortcuts

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