Documentation
¶
Overview ¶
Package module 提供模块的的相关功能。
Index ¶
- func NewMessage(msg string) error
- type Module
- func (m *Module) AddInit(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) GetInit() dependency.InitFunc
- func (m *Module) GetInstall(version string) dependency.InitFunc
- 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) Mux() *mux.Mux
- func (m *Module) NewVersion(version string) *Version
- 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
- func (m *Module) Task(version, title string, fn TaskFunc)
- 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 TaskFunc
- type Type
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMessage ¶
NewMessage 声明一条 message 类型的错误信息
返回内容并不是一个真正的错误,则是在某些时候需要在安装完成之后, 反馈一些文字信息,则需要用此函数进行包装。
Types ¶
type Module ¶
type Module struct {
Type Type
Name string
Deps []string
Description string
// 当前模块的所有路由项。
// 键名为路由地址,键值为路由中启用的请求方法。
Routes map[string][]string
// contains filtered or unexported fields
}
Module 表示模块信息
func (*Module) DeleteFunc ¶
DeleteFunc 指定一个 Delete 请求
func (*Module) GetInit ¶
func (m *Module) GetInit() dependency.InitFunc
GetInit 将 Module 的内容生成一个 dependency.InitFunc 函数
func (*Module) GetInstall ¶
func (m *Module) GetInstall(version string) dependency.InitFunc
GetInstall 运行当前模块的安装事件。此方法会被作为 dependency.InitFunc 被调用。
func (*Module) HandleFunc ¶
func (m *Module) HandleFunc(path string, h func(w http.ResponseWriter, r *http.Request), methods ...string) *Module
HandleFunc 指定一个请求
func (*Module) NewVersion ¶
NewVersion 为当前模块添加某一版本号下的安装脚本。
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.