Initial import.

This commit is contained in:
2021-04-19 13:10:40 -07:00
commit 42aa585bd0
16 changed files with 863 additions and 0 deletions

30
conn/http/server.go Normal file
View File

@@ -0,0 +1,30 @@
package http
import (
"log"
"net/http"
"sync"
)
// Main router
// Twilio handler
var server = &struct {
router *http.ServeMux
lock sync.Mutex
}{
router: http.NewServeMux(),
}
// AddRoute is used to set up routes.
//
// NB: no checking is done yet for duplicate patterns.
func AddRoute(pattern string, handler func(http.ResponseWriter, *http.Request)) {
server.lock.Lock()
defer server.lock.Unlock()
server.router.HandleFunc(pattern, handler)
}
func Start(addr string) {
go log.Print(http.ListenAndServe(addr, server.router))
}