X-Git-Url: https://code.octet-stream.net/broadcaster/blobdiff_plain/d14180328760fa282068927068ca5675b9427bc2..8320951221d45c5f5f3d387c5cb4b97d9fa2094c:/server/broadcaster.go diff --git a/server/broadcaster.go b/server/broadcaster.go index d2495fd..e5f9922 100644 --- a/server/broadcaster.go +++ b/server/broadcaster.go @@ -33,6 +33,7 @@ func main() { InitDatabase() defer db.CloseDatabase() + InitCommandRouter() InitPlaylists() InitAudioFiles(config.AudioFilesPath) InitServerStatus() @@ -41,6 +42,7 @@ func main() { http.HandleFunc("/login", logInPage) http.HandleFunc("/logout", logOutPage) http.HandleFunc("/secret", secretPage) + http.HandleFunc("/stop", stopPage) http.HandleFunc("/playlist/", playlistSection) http.HandleFunc("/file/", fileSection) @@ -404,3 +406,19 @@ func logOutPage(w http.ResponseWriter, r *http.Request) { tmpl := template.Must(template.ParseFiles("templates/logout.html")) tmpl.Execute(w, nil) } + +func stopPage(w http.ResponseWriter, r *http.Request) { + _, err := currentUser(w, r) + if err != nil { + http.Redirect(w, r, "/login", http.StatusFound) + return + } + r.ParseForm() + radioId, err := strconv.Atoi(r.Form.Get("radioId")) + if err != nil { + http.NotFound(w, r) + return + } + commandRouter.Stop(radioId) + http.Redirect(w, r, "/", http.StatusFound) +}