Start Twilio webhook.
This commit is contained in:
@@ -26,5 +26,6 @@ func AddRoute(pattern string, handler func(http.ResponseWriter, *http.Request))
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Start(addr string) {
|
func Start(addr string) {
|
||||||
|
log.Printf("starting HTTP server on %s", addr)
|
||||||
go log.Print(http.ListenAndServe(addr, server.router))
|
go log.Print(http.ListenAndServe(addr, server.router))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,3 +47,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Printf("twilio receive hook: %s", err)
|
log.Printf("twilio receive hook: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Start() error {
|
||||||
|
http.AddRoute("/twilio", handler)
|
||||||
|
}
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -53,6 +53,8 @@ func main() {
|
|||||||
if cfg.Connections.Twilio != nil {
|
if cfg.Connections.Twilio != nil {
|
||||||
if err = twilio.SetConfig(cfg.Connections.Twilio); err != nil {
|
if err = twilio.SetConfig(cfg.Connections.Twilio); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
} else {
|
||||||
|
twilio.Start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user