router

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET    = 1
	HEAD   = 1 << 1
	POST   = 1 << 2
	PUT    = 1 << 3
	PATCH  = 1 << 4
	DELETE = 1 << 5
	OPTION = 1 << 6
	ANY    = GET | HEAD | POST | PUT | PATCH | DELETE | OPTION
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupHandler

type GroupHandler func(r *Router)

type ParamRoute

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

ParamRoute isParam route node

func (*ParamRoute) Handler

func (p *ParamRoute) Handler() RouteHandler

Handler route handler

func (*ParamRoute) IsValid

func (p *ParamRoute) IsValid() bool

func (*ParamRoute) Middleware

func (p *ParamRoute) Middleware() []string

func (*ParamRoute) Partials

func (p *ParamRoute) Partials() []pathPartial

Partials partials of route path

func (*ParamRoute) Path

func (p *ParamRoute) Path() string

Path path

func (*ParamRoute) SetMiddleware

func (p *ParamRoute) SetMiddleware(middleware []string)

type RouteHandler

RouteHandler normal route handler

func NewRouteHandlerFromHttp

func NewRouteHandlerFromHttp(h http.Handler) RouteHandler

type Router

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

Router app router

func NewRouter

func NewRouter(app *kernel.Application) *Router

func (*Router) BindController

func (r *Router) BindController(name string, controller interface{})

BindController bind single controller

func (*Router) BindControllers

func (r *Router) BindControllers(controllers map[string]interface{})

BindControllers bind controllers

func (*Router) CRUD

func (r *Router) CRUD(path string, handler ApiCRUDHandler, middleware ...string)

CRUD register simple crud routes

func (*Router) Delete

func (r *Router) Delete(path string, handler interface{}) *RoutesHolder

func (*Router) Dispatch

func (*Router) Get

func (r *Router) Get(path string, handler interface{}) *RoutesHolder

Get get method router

func (*Router) Group

func (r *Router) Group(g GroupHandler, prefix string, middleware ...string)

func (*Router) HandleDelete

func (r *Router) HandleDelete(path string, handler RouteHandler) *RoutesHolder

func (*Router) HandleGet

func (r *Router) HandleGet(path string, handler RouteHandler) *RoutesHolder

HandleGet get method with route handler

func (*Router) HandlePatch

func (r *Router) HandlePatch(path string, handler RouteHandler) *RoutesHolder

func (*Router) HandlePost

func (r *Router) HandlePost(path string, handler RouteHandler) *RoutesHolder

func (*Router) HandlePut

func (r *Router) HandlePut(path string, handler RouteHandler) *RoutesHolder

func (*Router) Match

func (r *Router) Match(req contract.RequestContract) *ParamRoute

func (*Router) Patch

func (r *Router) Patch(path string, handler interface{}) *RoutesHolder

func (*Router) Post

func (r *Router) Post(path string, handler interface{}) *RoutesHolder

func (*Router) Put

func (r *Router) Put(path string, handler interface{}) *RoutesHolder

func (*Router) Register

func (r *Router) Register(method int, path string, handler RouteHandler) *RoutesHolder

Register register route

func (*Router) RegisterAction

func (r *Router) RegisterAction(method int, path string, handler interface{}) *RoutesHolder

RegisterAction register route with giving handler

'handler' can be string(eg: "home@Index",), RouteHandler
or any func returns string,RequestContract,[]byte or JsonAble

type RoutesHolder

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

func (*RoutesHolder) Middleware

func (rh *RoutesHolder) Middleware(middleware ...string) *RoutesHolder

func (*RoutesHolder) Prefix

func (rh *RoutesHolder) Prefix(prefix string) *RoutesHolder

Jump to

Keyboard shortcuts

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