Browse Source

Add web listen address as config variable

Toni Fadjukoff 6 years ago
parent
commit
6ad8a9380d
2 changed files with 4 additions and 3 deletions
  1. 2 1
      bot.go
  2. 2 2
      web.go

+ 2 - 1
bot.go View File

@@ -24,6 +24,7 @@ var credentials struct {
24 24
 	Password            string
25 25
 	SpotifyClientID     string
26 26
 	SpotifyClientSecret string
27
+	ListenAddr          string
27 28
 }
28 29
 
29 30
 func appendSong(wikiText string, author string, newSong string) string {
@@ -323,7 +324,7 @@ func main() {
323 324
 	spotifyClient := spotify.NewClient(credentials.SpotifyClientID, credentials.SpotifyClientSecret)
324 325
 	go func() {
325 326
 
326
-		webStart(modifiedSongChan, spotifyClient)
327
+		webStart(credentials.ListenAddr, modifiedSongChan, spotifyClient)
327 328
 	}()
328 329
 
329 330
 	go func() {

+ 2 - 2
web.go View File

@@ -183,7 +183,7 @@ func loginHandler(w http.ResponseWriter, r *http.Request) {
183 183
 	http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
184 184
 }
185 185
 
186
-func webStart(modifiedSongChan chan *SongEntry, spot *spotify.SpotifyClient) {
186
+func webStart(listenAddr string, modifiedSongChan chan *SongEntry, spot *spotify.SpotifyClient) {
187 187
 	songsChan = modifiedSongChan
188 188
 	spotifyClient = spot
189 189
 
@@ -198,5 +198,5 @@ func webStart(modifiedSongChan chan *SongEntry, spot *spotify.SpotifyClient) {
198 198
 	mux.HandleFunc("/update", updateHandler)
199 199
 	mux.HandleFunc("/login", loginHandler)
200 200
 
201
-	http.ListenAndServe("localhost:8080", mux)
201
+	http.ListenAndServe(listenAddr, mux)
202 202
 }