Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ale
autoradio
Commits
a4b78e24
Commit
a4b78e24
authored
Apr 13, 2019
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass /admin/metadata along to the Icecast leader
parent
b82f0263
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
node/http.go
node/http.go
+20
-0
No files found.
node/http.go
View file @
a4b78e24
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment