Skip to content

Commit bfc9fc5

Browse files
committed
fixed config keys
1 parent 2f45c49 commit bfc9fc5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

webserver/handle.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func handleFetchQuestions(w http.ResponseWriter, r *http.Request) {
4343
w.Write([]byte("{\"message\":\"missing required key \\\"password\\\"!\"}"))
4444
return
4545
}
46-
if body.Password != viper.GetString("connection.password") {
46+
if body.Password != viper.GetString("webserver.password") {
4747
w.WriteHeader(http.StatusForbidden)
4848
return
4949
}

webserver/handleWebsocket.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ func keepAlive(c *quiz.Connection) {
3939
})
4040

4141
for {
42-
time.Sleep(viper.GetDuration("read_timeout") / 3)
42+
time.Sleep(viper.GetDuration("webserver.read_timeout") / 3)
4343
if c.WS == nil {
4444
return
4545
}
46-
if c.GetLastResponse() > viper.GetDuration("read_timeout") {
46+
if c.GetLastResponse() > viper.GetDuration("webserver.read_timeout") {
4747
log.Printf("App did not respond in time! Last response was %s ago. Closing connection...", c.GetLastResponse())
4848
c.Close()
4949
return
5050
}
51-
err := c.WS.WriteControl(websocket.PingMessage, []byte("PING"), time.Now().Add(viper.GetDuration("read_timeout")))
51+
err := c.WS.WriteControl(websocket.PingMessage, []byte("PING"), time.Now().Add(viper.GetDuration("webserver.read_timeout")))
5252
if err != nil {
5353
log.Printf("Failed to send websocket ping message: %v | Closing connection...", err)
5454
c.Close()

0 commit comments

Comments
 (0)