Skip to content
Snippets Groups Projects
Commit a4b78e24 authored by ale's avatar ale
Browse files

Pass /admin/metadata along to the Icecast leader

parent b82f0263
No related branches found
No related tags found
1 merge request!1v2.0
......@@ -12,6 +12,7 @@ import (
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
"strconv"
"strings"
......@@ -53,6 +54,25 @@ func newHTTPHandler(n *Node, icecastPort int, domain string) http.Handler {
mux.Handle("/debug/", h)
}
// A very narrow selection of Icecast API methods is served
// below /admin/ and forwarded to the Icecast master via a
// standard httputil.ReverseProxy.
adminHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
leaderAddr := n.leaderAddr()
if leaderAddr == "" {
http.Error(w, "No leader", http.StatusServiceUnavailable)
return
}
rp := httputil.NewSingleHostReverseProxy(&url.URL{
Scheme: "http",
Host: leaderAddr,
})
rp.ServeHTTP(w, r)
})
mux.Handle("/admin/metadata", adminHandler)
mux.Handle("/admin/killsource", adminHandler)
// Requests for /_stream/ go straight to the local Icecast.
proxyHandler := http.StripPrefix(autoradio.IcecastMountPrefix,
withMount(n, func(m *pb.Mount, w http.ResponseWriter, r *http.Request) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment