chore: refactor online request handler in separate files

This commit is contained in:
hytracer
2023-11-22 15:08:45 +01:00
parent 4d7d563c30
commit 8ee2db155a
2 changed files with 14 additions and 4 deletions

13
nas/online.go Normal file
View File

@@ -0,0 +1,13 @@
package nas
import (
"strconv"
"wwfc/common"
"net/http"
)
func returnOnlineStats(w http.ResponseWriter) {
w.Header().Set("Content-Type", "text/plain")
w.Header().Set("Content-Length", strconv.Itoa(len(strconv.Itoa(common.OnlineUsers))))
w.Write([]byte(strconv.Itoa(common.OnlineUsers)))
}

View File

@@ -10,7 +10,6 @@ import (
"strings"
"wwfc/logging"
"wwfc/sake"
"wwfc/common"
)
type Route struct {
@@ -76,9 +75,7 @@ func (route *Route) Handle() http.Handler {
// Check for /online
if strings.HasPrefix(r.URL.String(), "/online") {
w.Header().Set("Content-Type", "text/plain")
w.Header().Set("Content-Length", strconv.Itoa(len(strconv.Itoa(common.OnlineUsers))))
w.Write([]byte(strconv.Itoa(common.OnlineUsers)))
returnOnlineStats(w)
return
}