I'm trying to implement the RTMP protocol to along side my web application in Go, however I can't seem to figure out solution to handle both HTTP and and RTMP on the same port.
The idea would be something such as this.
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello!")
})
http.HandleFunc("/rtmp", func(w http.ResponseWriter, r *http.Request) {
// RTMP handling here
})
fmt.Println("Starting web server")
http.ListenAndServe(":8000", nil)
}
zhangpeihao/gortmp has a great RMTP module with an example that shows handling RTMP by listening on a TCP socket. However how can handle it on a specific endpoint rather then a second port?