mirror of
https://github.com/Sean-Der/fail2rest.git
synced 2024-12-22 13:42:17 +01:00
Add failRegex to jail info
This commit is contained in:
parent
405d61e729
commit
ba4bcaf440
2 changed files with 8 additions and 1 deletions
1
Makefile
1
Makefile
|
@ -6,3 +6,4 @@ run:
|
|||
libs:
|
||||
go get github.com/kisielk/og-rek
|
||||
go get github.com/gorilla/mux
|
||||
go get github.com/Sean-Der/fail2go
|
||||
|
|
8
jail.go
8
jail.go
|
@ -2,19 +2,24 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/Sean-Der/fail2go"
|
||||
"github.com/gorilla/mux"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func jailGetHandler(res http.ResponseWriter, req *http.Request) {
|
||||
jailStatus, _ := fail2go.JailStatus(mux.Vars(req)["jail"])
|
||||
jailFailRegex, _ := fail2go.JailFailRegex(mux.Vars(req)["jail"])
|
||||
|
||||
output := make(map[string]interface{})
|
||||
|
||||
for key, value := range jailStatus {
|
||||
output[key] = value
|
||||
}
|
||||
for key, value := range jailFailRegex {
|
||||
output[key] = value
|
||||
}
|
||||
|
||||
encodedOutput, err := json.Marshal(output)
|
||||
if err != nil {
|
||||
}
|
||||
|
@ -24,4 +29,5 @@ func jailGetHandler(res http.ResponseWriter, req *http.Request) {
|
|||
|
||||
func jailHandler(jailRouter *mux.Router) {
|
||||
jailRouter.HandleFunc("/{jail}", jailGetHandler).Methods("GET")
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue