Handle generated errors in server-webrtc

This commit is contained in:
Shane Howearth 2019-09-26 09:19:22 +10:00 committed by Cecylia Bocovich
parent 82e5753bcc
commit 3ec9dd19fa
3 changed files with 57 additions and 22 deletions

View file

@ -23,11 +23,14 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
case "GET":
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(http.StatusOK)
w.Write([]byte(`HTTP signaling channel
_, err := w.Write([]byte(`HTTP signaling channel
Send a POST request containing an SDP offer. The response will
contain an SDP answer.
`))
if err != nil {
log.Printf("GET request write failed with error: %v", err)
}
return
case "POST":
break
@ -57,7 +60,11 @@ contain an SDP answer.
log.Println("answering HTTP POST")
w.WriteHeader(http.StatusOK)
w.Write([]byte(pc.LocalDescription().Serialize()))
_, err = w.Write([]byte(pc.LocalDescription().Serialize()))
if err != nil {
log.Printf("answering HTTP POST write failed with error %v", err)
}
}
func receiveSignalsHTTP(addr string, config *webrtc.Configuration) error {