来自 github,https://github.com/CyCoreSystems/ari/blob/master/_examples/stasisStart/main.go
我正在查看下面的启动和对象被保存到 cl 并稍后用于创建 handlefun .. 所有在同一个主体中.. 如果我想打破它并将 handlefunc 放在另一个包中,我怎样才能将 cl 传递给它?
cl, err := native.Connect(&native.Options{
Application: "test",
Username: "asterisk",
Password: "abc123",
URL: "http://localhost:8088/ari",
WebsocketURL: "ws://localhost:8088/ari/events",
})
后来,这通过
http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// make call
log.Info("Make sample call")
h, err := createCall(cl)
if err != nil {
log.Error("Failed to create call", "error", err)
w.WriteHeader(http.StatusBadGateway)
w.Write([]byte("Failed to create call: " + err.Error()))
return
}
w.WriteHeader(http.StatusOK)
w.Write([]byte(h.ID()))
}))
噜噜哒
慕尼黑的夜晚无繁华
相关分类