func New(id idgen.IdGen) (sh *handlers) { if id == nil { id = idgen.NewObjectId() } sh = &handlers{ schan: make(chan os.Signal), cb: make(map[os.Signal][]*handler), id: id, } return }
func New(scriptPath, secret, rootUrl string) (h *Handler) { h = &Handler{ scriptPath: scriptPath, secret: secret, idgen: idgen.NewObjectId(), iptPool: iptpool.NewIptPool(NewLuaIpt), rootUrl: path.Clean(path.Join("/", rootUrl, "/")), } h.iptPool.OnCreate = func(ipt iptpool.ScriptIpt) error { ipt.Init(h.scriptPath) ipt.Bind("Call", h.call) ipt.Bind("Get", h.get) ipt.Bind("PostJSON", h.postJson) ipt.Bind("Post", h.post) ipt.Bind("Secret", h.secret) return nil } return h }