Documentation
¶
Overview ¶
Package app 核心功能的实现
Index ¶
- Constants
- func Grace(app *App, sig ...os.Signal)
- type App
- func (app *App) AddMiddlewares(m ...middleware.Middleware) *App
- func (app *App) CRITICAL() *log.Logger
- func (app *App) Close() error
- func (app *App) Config() *config.Manager
- func (app *App) Critical(v ...interface{})
- func (app *App) Criticalf(format string, v ...interface{})
- func (app *App) DEBUG() *log.Logger
- func (app *App) Debug(v ...interface{})
- func (app *App) Debugf(format string, v ...interface{})
- func (app *App) ERROR() *log.Logger
- func (app *App) Error(v ...interface{})
- func (app *App) ErrorHandlers() *errorhandler.ErrorHandler
- func (app *App) Errorf(format string, v ...interface{})
- func (app *App) Fatal(code int, v ...interface{})
- func (app *App) Fatalf(code int, format string, v ...interface{})
- func (app *App) File(path string) string
- func (app *App) FlushLogs()
- func (app *App) GetMessage(code int) (*messages.Message, bool)
- func (app *App) INFO() *log.Logger
- func (app *App) Info(v ...interface{})
- func (app *App) Infof(format string, v ...interface{})
- func (app *App) InitModules(tag string) error
- func (app *App) IsDebug() bool
- func (app *App) Load(r io.Reader, typ string, v interface{}) error
- func (app *App) LoadFile(path string, v interface{}) error
- func (app *App) Logs() *logs.Logs
- func (app *App) Messages(p *message.Printer) map[int]string
- func (app *App) Mimetypes() *mimetype.Mimetypes
- func (app *App) Modules() []*module.Module
- func (app *App) Mux() *mux.Mux
- func (app *App) NewMessages(status int, msgs map[int]string)
- func (app *App) NewModule(name, desc string, deps ...string) *module.Module
- func (app *App) Panic(v ...interface{})
- func (app *App) Panicf(format string, v ...interface{})
- func (app *App) RegisterOnShutdown(f func())
- func (app *App) Serve() error
- func (app *App) Shutdown() error
- func (app *App) TRACE() *log.Logger
- func (app *App) Tags() []string
- func (app *App) Trace(v ...interface{})
- func (app *App) Tracef(format string, v ...interface{})
- func (app *App) URL(path string) string
- func (app *App) WARN() *log.Logger
- func (app *App) Warn(v ...interface{})
- func (app *App) Warnf(format string, v ...interface{})
- type Apps
Constants ¶
View Source
const ( ConfigFilename = "web.yaml" LogsFilename = "logs.xml" )
框加需要用到的配置文件名。 实际路径需要通过 App.File 获取。
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App 程序运行实例
func (*App) AddMiddlewares ¶
func (app *App) AddMiddlewares(m ...middleware.Middleware) *App
AddMiddlewares 设置全局的中间件,可多次调用。
后添加的后调用。
func (*App) Critical ¶
func (app *App) Critical(v ...interface{})
Critical 相当于 CRITICAL().Println(v...)的简写方式
func (*App) ErrorHandlers ¶ added in v0.21.0
func (app *App) ErrorHandlers() *errorhandler.ErrorHandler
ErrorHandlers 错误处理功能
func (*App) GetMessage ¶ added in v0.21.0
GetMessage 查找指定代码的错误信息
func (*App) Info ¶
func (app *App) Info(v ...interface{})
Info 相当于 INFO().Println(v...) 的简写方式 Info 函数默认是带换行符的,若需要不带换行符的,请使用 DEBUG().Print() 函数代替。 其它相似函数也有类型功能。
func (*App) InitModules ¶
InitModules 执行模板的初始化函数。可以重复调用执行。
func (*App) NewMessages ¶ added in v0.21.0
NewMessages 添加新的错误消息
func (*App) RegisterOnShutdown ¶
func (app *App) RegisterOnShutdown(f func())
RegisterOnShutdown 等于于 http.Server.RegisterOnShutdown
func (*App) Serve ¶
Serve 加载各个模块的数据,运行路由,执行监听程序。
当调用 Shutdown 关闭服务时,会等待其完成未完的服务,才返回 http.ErrServerClosed
type Apps ¶ added in v0.21.0
type Apps struct {
// contains filtered or unexported fields
}
Apps 多个 App 实例的集合。可以实现多站点服务。 相关功能可以在 https://github.com/issue9/web/issues/5 进行跟踪。
Click to show internal directories.
Click to hide internal directories.