mirror of
https://github.com/Sean-Der/fail2rest.git
synced 2024-12-22 13:42:17 +01:00
Implement global/bans returns the contents of the Bans table from the persistent database introduced in 0.9.0
This commit is contained in:
parent
05ec165128
commit
4a19482e20
1 changed files with 15 additions and 1 deletions
16
global.go
16
global.go
|
@ -25,11 +25,21 @@ func globalPingHandler(res http.ResponseWriter, req *http.Request, fail2goConn *
|
|||
return
|
||||
}
|
||||
|
||||
|
||||
encodedOutput, _ := json.Marshal(globalPing)
|
||||
res.Write(encodedOutput)
|
||||
}
|
||||
|
||||
func globalBansHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
|
||||
globalBans, err := fail2goConn.GlobalBans()
|
||||
if err != nil {
|
||||
writeHTTPError(res, err)
|
||||
return
|
||||
}
|
||||
|
||||
encodedOutput, _ := json.Marshal(globalBans)
|
||||
res.Write(encodedOutput)
|
||||
}
|
||||
|
||||
func globalHandler(globalRouter *mux.Router, fail2goConn *fail2go.Conn) {
|
||||
globalRouter.HandleFunc("/status", func(res http.ResponseWriter, req *http.Request) {
|
||||
globalStatusHandler(res, req, fail2goConn)
|
||||
|
@ -37,4 +47,8 @@ func globalHandler(globalRouter *mux.Router, fail2goConn *fail2go.Conn) {
|
|||
globalRouter.HandleFunc("/ping", func(res http.ResponseWriter, req *http.Request) {
|
||||
globalPingHandler(res, req, fail2goConn)
|
||||
}).Methods("GET")
|
||||
globalRouter.HandleFunc("/bans", func(res http.ResponseWriter, req *http.Request) {
|
||||
globalBansHandler(res, req, fail2goConn)
|
||||
}).Methods("GET")
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue