ソースを参照

Add web listen address as config variable

Toni Fadjukoff 6 年 前
コミット
6ad8a9380d
共有2 個のファイルを変更した4 個の追加3 個の削除を含む
  1. 2 1
      bot.go
  2. 2 2
      web.go

+ 2 - 1
bot.go ファイルの表示

@@ -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 ファイルの表示

@@ -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
 }