1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-03 16:38:31 +00:00

Fix the build (move out of internal)

This commit is contained in:
Kane York 2015-11-16 13:28:16 -08:00
parent c38b9b0018
commit 58dd0bd9ee
15 changed files with 4 additions and 5 deletions

View file

@ -0,0 +1,48 @@
package server
import (
"bytes"
"encoding/json"
"net/http"
)
type StatsData struct {
ClientConnectsTotal int64
ClientDisconnectsTotal int64
FirstNotHelloDisconnects int64
DisconnectCodes map[string]int64
DisconnectReasons map[string]int64
CommandsIssuedTotal int64
CommandsIssuedMap map[Command]int64
MessagesSent int64
Version int
}
const StatsDataVersion = 1
func newStatsData() *StatsData {
return &StatsData{
CommandsIssuedMap: make(map[Command]int64),
DisconnectCodes: make(map[string]int64),
DisconnectReasons: make(map[string]int64),
Version: StatsDataVersion,
}
}
// Statistics is several variables that get incremented during normal operation of the server.
// Its structure should be versioned as it is exposed via JSON.
var Statistics = newStatsData()
func HTTPShowStatistics(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
jsonBytes, _ := json.Marshal(Statistics)
outBuf := bytes.NewBuffer(nil)
json.Indent(outBuf, jsonBytes, "", "\t")
outBuf.WriteTo(w)
}