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
 	Password            string
24
 	Password            string
25
 	SpotifyClientID     string
25
 	SpotifyClientID     string
26
 	SpotifyClientSecret string
26
 	SpotifyClientSecret string
27
+	ListenAddr          string
27
 }
28
 }
28
 
29
 
29
 func appendSong(wikiText string, author string, newSong string) string {
30
 func appendSong(wikiText string, author string, newSong string) string {
323
 	spotifyClient := spotify.NewClient(credentials.SpotifyClientID, credentials.SpotifyClientSecret)
324
 	spotifyClient := spotify.NewClient(credentials.SpotifyClientID, credentials.SpotifyClientSecret)
324
 	go func() {
325
 	go func() {
325
 
326
 
326
-		webStart(modifiedSongChan, spotifyClient)
327
+		webStart(credentials.ListenAddr, modifiedSongChan, spotifyClient)
327
 	}()
328
 	}()
328
 
329
 
329
 	go func() {
330
 	go func() {

+ 2 - 2
web.go View File

183
 	http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
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
 	songsChan = modifiedSongChan
187
 	songsChan = modifiedSongChan
188
 	spotifyClient = spot
188
 	spotifyClient = spot
189
 
189
 
198
 	mux.HandleFunc("/update", updateHandler)
198
 	mux.HandleFunc("/update", updateHandler)
199
 	mux.HandleFunc("/login", loginHandler)
199
 	mux.HandleFunc("/login", loginHandler)
200
 
200
 
201
-	http.ListenAndServe("localhost:8080", mux)
201
+	http.ListenAndServe(listenAddr, mux)
202
 }
202
 }