Documentation ¶
Overview ¶
core 提供全局可用变量, 方法. 全局可用的类型定义请 import "github.com/typepress/types"
Index ¶
- Constants
- Variables
- func FireSignal(sig os.Signal, remove bool)
- func Handler(handler ...martini.Handler)
- func ListenSignal(fn func(os.Signal) bool, sigs ...os.Signal)
- func Martini(handler ...martini.Handler) (*martini.Martini, martini.Router)
- func RBAC(rs []string) martini.Handler
- func Recover(fn func()) (err interface{})
- func RegisterInit(fn ...func())
- func RolesSet(rs ...string)
- func RolesToRole(rs []string) (x Role)
- func RouterDispatch(res http.ResponseWriter, req *http.Request, c martini.Context)
Constants ¶
View Source
const ( SessionName = "TPSession" ServerShutDown = "ServerShutDown" )
Variables ¶
View Source
var ( // global Conf toml.Toml Log log.Loggers Db db.Database PWD string RouterGet martini.Router // GET method only RouterPut martini.Router // PUT method only RouterHead martini.Router // HEAD method only RouterPost martini.Router // POST method only RouterAjax martini.Router // POST method only, with head: X-Requested-With "XMLHttpRequest" RouterPatch martini.Router // PATCH method only RouterDelete martini.Router // DELETE method only RouterOptions martini.Router // OPTIONS method only RouterAny martini.Router // Any method )
Functions ¶
func FireSignal ¶
FireSignal 按照 LIFO 的次序调用 Listen 增加的监听函数. 如果捕获到 panic 中断调用, 并且监听函数会被剔除. 参数: sig 指示触发信号 remove 指示触发后是否剔除掉所有的触发函数
func ListenSignal ¶
ListenSignal 为监听 sigs 信号增加执行函数. 参数: fn 执行函数, 返回值如果是 true, 表示触发后剔除此函数. sigs 为一组要监听的信号, 支持系统信号和自定义信号.
func Martini ¶
返回内建 *Martini 和主 Router, 只能调用一次, 再次调用返回 nil. 参数 handler 会优先于通过 Handler 添加的 handler 执行. 已经执行过 .Action(Router.Handle)
func RBAC ¶
RBAC 返回用于角色控制的 Handler 依据 RolesSet 设置的字符串角色集合对参数 rs 进行计算, 得到 types.Role 值并使用 accessflags 生成 Handler
func RolesSet ¶
func RolesSet(rs ...string)
RolesSet 设置字符串角色名称集合, 用于角色控制. 如果要启用角色控制, 必须在注册路由之前进行设置. 字符串值会被转化为小写, 排序, 剔重. 为 accessflags 传递 types.Role 值做准备.
func RolesToRole ¶
func RolesToRole(rs []string) (x Role)
依据 RolesSet 设置的字符串角色集合对参数 rs 进行计算, 返回 types.Role 值.
func RouterDispatch ¶
RouterDispatch 仅用于主路由, 根据 req.Method 分派子路由.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.