mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-09-06 23:55:28 -05:00
chore: refactor online request handler in separate files
This commit is contained in:
13
nas/online.go
Normal file
13
nas/online.go
Normal 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)))
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user