dispatcher

package
v0.0.0-...-83425ee Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKeys

func CreateKeys(path string) []string

Types

type ControllerInterface

type ControllerInterface interface {
	Init(context *context.Context)
	Serve()
	Done()
	RecoverFunc(context *context.Context)
}

type Dispatcher

type Dispatcher struct {
	Middleware []middlewares.Middleware
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher() *Dispatcher

func (*Dispatcher) AddRoute

func (h *Dispatcher) AddRoute(method string, path string, handleMethod string, handler interface{}) error

func (*Dispatcher) Ready

func (h *Dispatcher) Ready()

nesting middlewares

func (*Dispatcher) ServeHTTP

func (h *Dispatcher) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Node

type Node struct {
	Children map[string]*Node
	Name     string

	Parameter        bool // if the parameter node, like /:id
	ParameterName    string
	HasParameterNode bool

	PathEnd      bool        // the endpoint of path, ex: the C is the endpoint of path /a/b/C
	Value        interface{} // controller that deal the bussiness logic
	HandleMethod string
}

func CreateNode

func CreateNode(key_value *string) *Node

func (*Node) ParameterNode

func (n *Node) ParameterNode() (*Node, error)

type RouteServe

type RouteServe struct {
	// contains filtered or unexported fields
}

func (*RouteServe) MiddlewareCall

func (t *RouteServe) MiddlewareCall(mr *middlewares.MiddlewareResponse, r *http.Request)

type Tree

type Tree struct {
	Root *Node
}

TrieTree

func (*Tree) Add

func (t *Tree) Add(path string, handleMethod string, handler interface{}) error

func (*Tree) FindHandler

func (t *Tree) FindHandler(path string) (interface{}, map[string]string, string, error)

Jump to

Keyboard shortcuts

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