web

package
v0.0.0-...-fdde285 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnexpectedType            = fmt.Errorf("unexpected-type")
	ErrMismatchNumberOfVariables = fmt.Errorf("mismatch-number-of-variables")
)

Functions

func Walk

func Walk(r *Router, use func(*WalkerNode) error) error

Types

type MetaData

type MetaData struct {
	Method string
	Path   string

	ExtraDependencies []interface{}
	Parent            *MetaData

	// additional
	Name              string // if not renamed, the value is  ""
	Description       string
	DefaultStatusCode int // if 0 -> 200
	Tags              []string
}

func GetMetaData

func GetMetaData(node *Node) MetaData

type Node

type Node = pathpattern.Node

type PathInfo

type PathInfo struct {
	Def      *resolve.Def
	VarNames []string
	Vars     map[string]*PathVar // argname -> PathVar
}

func ExtractPathInfo

func ExtractPathInfo(pathParameters []string, def *resolve.Def) (*PathInfo, error)

type PathVar

type PathVar struct {
	Name  string // not argname (e.g. /{articleId} and func(articleID string) { ... })
	Regex string
	Shape reflectshape.Shape
}

type Router

type Router struct {
	Root         *Node
	ErrorHandler func(error)

	Parent   *Router // []*Router?
	MetaData *MetaData

	FullPrefix string
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter() *Router

func (*Router) Connect

func (r *Router) Connect(pattern string, fn T, options ...RoutingOption) *Node

func (*Router) Delete

func (r *Router) Delete(pattern string, fn T, options ...RoutingOption) *Node

func (*Router) Get

func (r *Router) Get(pattern string, fn T, options ...RoutingOption) *Node

func (*Router) Group

func (r *Router) Group(pattern string, use func(*Router)) *Router

func (*Router) Head

func (r *Router) Head(pattern string, fn T, options ...RoutingOption) *Node

func (*Router) Method

func (r *Router) Method(method, pattern string, fn T, options ...RoutingOption) *Node

func (*Router) Options

func (r *Router) Options(pattern string, fn T, options ...RoutingOption) *Node

func (*Router) Patch

func (r *Router) Patch(pattern string, fn T, options ...RoutingOption) *Node

func (*Router) Post

func (r *Router) Post(pattern string, fn T, options ...RoutingOption) *Node

func (*Router) Put

func (r *Router) Put(pattern string, fn T, options ...RoutingOption) *Node

func (*Router) Trace

func (r *Router) Trace(pattern string, fn T, options ...RoutingOption) *Node

type RoutingOption

type RoutingOption func(*Node, *MetaData)

func WithAnotherHandlerName

func WithAnotherHandlerName(name string) RoutingOption

func WithDefaultStatusCode

func WithDefaultStatusCode(code int) RoutingOption

func WithExtraDependencies

func WithExtraDependencies(deps ...interface{}) RoutingOption

func WithTags

func WithTags(tags ...string) RoutingOption

type T

type T = interface{}

type WalkerNode

type WalkerNode struct {
	Node    *Node
	History []pathpattern.Suffix
}

func (*WalkerNode) Path

func (n *WalkerNode) Path() []string

Directories

Path Synopsis
Package pathpattern implements path matching.
Package pathpattern implements path matching.

Jump to

Keyboard shortcuts

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