Skip to content

Commit 4a19482

Browse files
committed
Implement global/bans returns the contents of the Bans table from the persistent database introduced in 0.9.0
1 parent 05ec165 commit 4a19482

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

global.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,30 @@ func globalPingHandler(res http.ResponseWriter, req *http.Request, fail2goConn *
2525
return
2626
}
2727

28-
2928
encodedOutput, _ := json.Marshal(globalPing)
3029
res.Write(encodedOutput)
3130
}
3231

32+
func globalBansHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
33+
globalBans, err := fail2goConn.GlobalBans()
34+
if err != nil {
35+
writeHTTPError(res, err)
36+
return
37+
}
38+
39+
encodedOutput, _ := json.Marshal(globalBans)
40+
res.Write(encodedOutput)
41+
}
42+
3343
func globalHandler(globalRouter *mux.Router, fail2goConn *fail2go.Conn) {
3444
globalRouter.HandleFunc("/status", func(res http.ResponseWriter, req *http.Request) {
3545
globalStatusHandler(res, req, fail2goConn)
3646
}).Methods("GET")
3747
globalRouter.HandleFunc("/ping", func(res http.ResponseWriter, req *http.Request) {
3848
globalPingHandler(res, req, fail2goConn)
3949
}).Methods("GET")
50+
globalRouter.HandleFunc("/bans", func(res http.ResponseWriter, req *http.Request) {
51+
globalBansHandler(res, req, fail2goConn)
52+
}).Methods("GET")
53+
4054
}

0 commit comments

Comments
 (0)