app

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package app 核心功能的实现

Index

Constants

View Source
const (
	ConfigFilename = "web.yaml"
	LogsFilename   = "logs.xml"
)

框加需要用到的配置文件名。 实际路径需要通过 App.File 获取。

Variables

This section is empty.

Functions

func Grace

func Grace(app *App, sig ...os.Signal)

Grace 指定触发 Shutdown() 的信号,若为空,则任意信号都触发。

多次调用,则每次指定的信号都会起作用,如果由传递了相同的值, 则有可能多次触发 Shutdown()。

NOTE: 传递空值,与不调用,其结果是不同的。 若是不调用,则不会处理任何信号;若是传递空值调用,则是处理任何要信号。

Types

type App

type App struct {
	*module.Modules
	// contains filtered or unexported fields
}

App 程序运行实例

func New

func New(mgr *config.Manager) (*App, error)

New 声明一个新的 App 实例

日志系统会在此处初始化。

func (*App) AddCompresses added in v0.25.0

func (app *App) AddCompresses(m map[string]compress.WriterFunc) error

AddCompresses 添加压缩处理函数

func (*App) Close

func (app *App) Close() error

Close 关闭服务。

无论配置文件如果设置,此函数都是直接关闭服务,不会等待。

func (*App) Config

func (app *App) Config() *config.Manager

Config 获取 config.Manager 的实例

func (*App) ErrorHandlers added in v0.21.0

func (app *App) ErrorHandlers() *errorhandler.ErrorHandler

ErrorHandlers 错误处理功能

func (*App) IsDebug

func (app *App) IsDebug() bool

IsDebug 是否处于调试模式

func (*App) LocalPrinter added in v0.25.0

func (app *App) LocalPrinter(tag language.Tag, opts ...message.Option) *message.Printer

LocalPrinter 获取本地化的输出对象

func (*App) Logs

func (app *App) Logs() *logs.Logs

Logs 获取 logs.Logs 实例

func (*App) Messages added in v0.21.0

func (app *App) Messages() *messages.Messages

Messages 返回 messages.Messages 实例

func (*App) Mimetypes

func (app *App) Mimetypes() *mimetype.Mimetypes

Mimetypes 返回 mimetype.Mimetypes

func (*App) Path added in v0.22.0

func (app *App) Path(p string) string

Path 获取中径部分的地址

基于 app.webConfig.URL 中的路径部分。

func (*App) Serve

func (app *App) Serve() (err error)

Serve 加载各个模块的数据,运行路由,执行监听程序。

当调用 Shutdown 关闭服务时,会等待其完成未完的服务,才返回 http.ErrServerClosed

func (*App) Server added in v0.25.0

func (app *App) Server() *http.Server

Server 获取 http.Server 实例

func (*App) Shutdown

func (app *App) Shutdown() error

Shutdown 关闭所有服务。

根据配置文件中的配置项,决定当前是直接关闭还是延时之后关闭。

func (*App) URL

func (app *App) URL(path string) string

URL 构建一条基于 app.webconfig.URL 的完整 URL

Jump to

Keyboard shortcuts

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