Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHandlerFuncName ¶
func GetHandlerFuncName(h http.HandlerFunc, seps ...rune) string
GetHandlerFuncName 通过反射获取函数名称
Types ¶
type AutherFunc ¶
The AutherFunc type is an adapter to allow the use of ordinary functions as Auther handlers. If f is a function with the appropriate signature, AutherFunc(f) is a Handler that calls f.
type Entry ¶
type Entry struct { Path string `json:"path,omitempty"` Method string `json:"method,omitempty"` FunctionName string `json:"function_name,omitempty"` Resource string `json:"resource,omitempty"` Protected bool `json:"protected"` Labels map[string]string `json:"labels,omitempty"` }
Entry 路由条目
func (*Entry) AddLabel ¶ added in v0.1.4
func (e *Entry) AddLabel(labels ...*Label) EntryDecorator
AddLabel 添加Label
type EntryDecorator ¶ added in v0.1.4
type EntryDecorator interface { // SetLabel 设置子路由标签, 作用于Entry上 AddLabel(...*Label) EntryDecorator }
EntryDecorator 装饰
type EntrySet ¶ added in v0.1.2
type EntrySet struct {
Items []*Entry `json:"items"`
}
EntrySet 路由条目集
type Middleware ¶
Middleware 中间件的函数签名
type MiddlewareFunc ¶
MiddlewareFunc is an adapter to allow the use of ordinary functions as Negroni handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler object that calls f.
type ResourceRouter ¶ added in v0.1.2
ResourceRouter 资源路由
type Router ¶
type Router interface { // 添加中间件 Use(m Middleware) // 添加受认证保护的路由 AddProtected(method, path string, h http.HandlerFunc) // 添加公开路由, 所有人都可以访问 AddPublict(method, path string, h http.HandlerFunc) // 开始认证时 使用的认证器 SetAuther(Auther) // 实现标准库路由 ServeHTTP(http.ResponseWriter, *http.Request) // 获取当前的路由条目信息 GetEndpoints() *EntrySet // EnableAPIRoot 将服务路由表通过路径/暴露出去 EnableAPIRoot() // 设置路由的Logger, 用于Debug SetLogger(logger.Logger) // SetLabel 设置路由标签, 作用于Entry上 SetLabel(...*Label) // 子路由 SubRouter(basePath string) SubRouter }
Router 路由
type SubRouter ¶
type SubRouter interface { // 添加中间件 Use(m Middleware) // SetLabel 设置路由标签, 作用于Entry上 SetLabel(...*Label) // With独立作用于某一个Handler With(m ...Middleware) SubRouter // 添加受认证保护的路由 AddProtected(method, path string, h http.HandlerFunc) EntryDecorator // 添加公开路由, 所有人都可以访问 AddPublict(method, path string, h http.HandlerFunc) EntryDecorator // ResourceRouter 资源路由器, 主要用于设置路由标签和资源名称,方便配置灵活的权限策略 ResourceRouter(resourceName string, labels ...*Label) ResourceRouter }
SubRouter 子路由或者分组路由
Click to show internal directories.
Click to hide internal directories.