Files
livekit/pkg/service/utils.go
David Zhao d9059f4f3b Do not accept websocket connection if response not received (#923)
When the instance handling the signal request did not respond to the
initial connection, we will fail the connection attempt instead of
having it hang forever.
2022-08-16 19:57:41 -07:00

25 lines
593 B
Go

package service
import (
"net/http"
"regexp"
"github.com/livekit/protocol/logger"
)
func handleError(w http.ResponseWriter, status int, err error, keysAndValues ...interface{}) {
keysAndValues = append(keysAndValues, "status", status)
logger.Warnw("error handling request", err, keysAndValues...)
w.WriteHeader(status)
_, _ = w.Write([]byte(err.Error()))
}
func boolValue(s string) bool {
return s == "1" || s == "true"
}
func IsValidDomain(domain string) bool {
domainRegexp := regexp.MustCompile(`^(?i)[a-z0-9-]+(\.[a-z0-9-]+)+\.?$`)
return domainRegexp.MatchString(domain)
}