Documentation
¶
Overview ¶
Package module 提供模块的的相关功能。
Index ¶
- type Init
- type Module
- func (m *Module) AddInit(f func() error) *Module
- func (m *Module) AddInitTitle(title string, f func() error) *Module
- func (m *Module) Delete(path string, h http.Handler) *Module
- func (m *Module) DeleteFunc(path string, h func(w http.ResponseWriter, r *http.Request)) *Module
- func (m *Module) Get(path string, h http.Handler) *Module
- func (m *Module) GetFunc(path string, h func(w http.ResponseWriter, r *http.Request)) *Module
- func (m *Module) Handle(path string, h http.Handler, methods ...string) *Module
- func (m *Module) HandleFunc(path string, h func(w http.ResponseWriter, r *http.Request), methods ...string) *Module
- func (m *Module) NewTag(tag string) *Module
- func (m *Module) Patch(path string, h http.Handler) *Module
- func (m *Module) PatchFunc(path string, h func(w http.ResponseWriter, r *http.Request)) *Module
- func (m *Module) Post(path string, h http.Handler) *Module
- func (m *Module) PostFunc(path string, h func(w http.ResponseWriter, r *http.Request)) *Module
- func (m *Module) Prefix(prefix string) *Prefix
- func (m *Module) Put(path string, h http.Handler) *Module
- func (m *Module) PutFunc(path string, h func(w http.ResponseWriter, r *http.Request)) *Module
- type Prefix
- func (p *Prefix) Delete(path string, h http.Handler) *Prefix
- func (p *Prefix) DeleteFunc(path string, f http.HandlerFunc) *Prefix
- func (p *Prefix) Get(path string, h http.Handler) *Prefix
- func (p *Prefix) GetFunc(path string, f http.HandlerFunc) *Prefix
- func (p *Prefix) Handle(path string, h http.Handler, methods ...string) *Prefix
- func (p *Prefix) HandleFunc(path string, f http.HandlerFunc, methods ...string) *Prefix
- func (p *Prefix) Module() *Module
- func (p *Prefix) Patch(pattern string, h http.Handler) *Prefix
- func (p *Prefix) PatchFunc(path string, f http.HandlerFunc) *Prefix
- func (p *Prefix) Post(path string, h http.Handler) *Prefix
- func (p *Prefix) PostFunc(path string, f http.HandlerFunc) *Prefix
- func (p *Prefix) Put(pattern string, h http.Handler) *Prefix
- func (p *Prefix) PutFunc(path string, f http.HandlerFunc) *Prefix
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct {
Type Type
Name string
Deps []string
Description string
// 第一个键名为路径,第二键名为请求方法
Routes map[string]map[string]http.Handler
// 一些初始化函数
Inits []*Init
// 保存特定标签下的子模块。
Tags map[string]*Module
}
Module 表示模块信息
func New ¶
New 声明一个新的模块
name 模块名称,需要全局唯一; desc 模块的详细信息; deps 表示当前模块的依赖模块名称,可以是插件中的模块名称。
仅供框架内部使用,不保证函数签名的兼容性。
func (*Module) AddInitTitle ¶ added in v0.16.1
AddInitTitle 添加一个初始化函数,带描述信息。
func (*Module) DeleteFunc ¶
DeleteFunc 指定一个 Delete 请求
func (*Module) HandleFunc ¶
func (m *Module) HandleFunc(path string, h func(w http.ResponseWriter, r *http.Request), methods ...string) *Module
HandleFunc 指定一个请求
type Prefix ¶
type Prefix struct {
// contains filtered or unexported fields
}
Prefix 可以将具有统一前缀的路由项集中在一起操作。
p := srv.Prefix("/api")
p.Get("/users") // 相当于 srv.Get("/api/users")
p.Get("/user/1") // 相当于 srv.Get("/api/user/1")
func (*Prefix) DeleteFunc ¶
func (p *Prefix) DeleteFunc(path string, f http.HandlerFunc) *Prefix
DeleteFunc 指定一个 Delete 请求
func (*Prefix) GetFunc ¶
func (p *Prefix) GetFunc(path string, f http.HandlerFunc) *Prefix
GetFunc 指定一个 Get 请求
func (*Prefix) HandleFunc ¶
HandleFunc 指定一个请求
func (*Prefix) PatchFunc ¶
func (p *Prefix) PatchFunc(path string, f http.HandlerFunc) *Prefix
PatchFunc 指定一个 Patch 请求
Click to show internal directories.
Click to hide internal directories.