Implement jailActionHandler at jail/{jail}/action/{action} this will be used to list properties for an jail action

This commit is contained in:
Sean DuBois 2014-11-22 05:02:08 +00:00
parent 4d84eda7db
commit eda3f9d57c

16
jail.go
View file

@ -203,6 +203,18 @@ func jailSetMaxRetryHandler(res http.ResponseWriter, req *http.Request, fail2goC
res.Write(encodedOutput)
}
func jailActionHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
port, err := fail2goConn.JailActionProperty(mux.Vars(req)["jail"], mux.Vars(req)["action"], "port")
if err != nil {
writeHTTPError(res, err)
return
}
encodedOutput, _ := json.Marshal(map[string]interface{}{
"port": port})
res.Write(encodedOutput)
}
func jailHandler(jailRouter *mux.Router, fail2goConn *fail2go.Conn) {
jailRouter.HandleFunc("/{jail}/bannedip", func(res http.ResponseWriter, req *http.Request) {
@ -235,6 +247,10 @@ func jailHandler(jailRouter *mux.Router, fail2goConn *fail2go.Conn) {
jailSetMaxRetryHandler(res, req, fail2goConn)
}).Methods("POST")
jailRouter.HandleFunc("/{jail}/action/{action}", func(res http.ResponseWriter, req *http.Request) {
jailActionHandler(res, req, fail2goConn)
}).Methods("GET")
jailRouter.HandleFunc("/{jail}", func(res http.ResponseWriter, req *http.Request) {
jailGetHandler(res, req, fail2goConn)
}).Methods("GET")