Separate /live and / http handlers
Separate the /live and / (main) http handlers. This cleans up the related code a little bit and makes it a lot easier to follow.
This commit is contained in:
parent
e051cade78
commit
d06e2251a4
@ -408,7 +408,7 @@ func handlePlay(conn *rtmp.Conn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleDefault(w http.ResponseWriter, r *http.Request) {
|
func handleLive(w http.ResponseWriter, r *http.Request) {
|
||||||
l.RLock()
|
l.RLock()
|
||||||
ch := channels[strings.Trim(r.URL.Path, "/")]
|
ch := channels[strings.Trim(r.URL.Path, "/")]
|
||||||
l.RUnlock()
|
l.RUnlock()
|
||||||
@ -426,6 +426,11 @@ func handleDefault(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
avutil.CopyFile(muxer, cursor)
|
avutil.CopyFile(muxer, cursor)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleDefault(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Path != "/" {
|
if r.URL.Path != "/" {
|
||||||
// not really an error for the server, but for the client.
|
// not really an error for the server, but for the client.
|
||||||
common.LogInfoln("[http 404] ", r.URL.Path)
|
common.LogInfoln("[http 404] ", r.URL.Path)
|
||||||
@ -433,5 +438,4 @@ func handleDefault(w http.ResponseWriter, r *http.Request) {
|
|||||||
} else {
|
} else {
|
||||||
handleIndexTemplate(w, r)
|
handleIndexTemplate(w, r)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
1
main.go
1
main.go
@ -145,6 +145,7 @@ func startServer() {
|
|||||||
http.HandleFunc("/help", handleHelpTemplate)
|
http.HandleFunc("/help", handleHelpTemplate)
|
||||||
http.HandleFunc("/emotes", handleEmoteTemplate)
|
http.HandleFunc("/emotes", handleEmoteTemplate)
|
||||||
|
|
||||||
|
http.HandleFunc("/live", handleLive)
|
||||||
http.HandleFunc("/", handleDefault)
|
http.HandleFunc("/", handleDefault)
|
||||||
|
|
||||||
err := http.ListenAndServe(addr, nil)
|
err := http.ListenAndServe(addr, nil)
|
||||||
|
Loading…
Reference in New Issue
Block a user