25 lines
521 B
Go
25 lines
521 B
Go
package controllers
|
|
|
|
import (
|
|
"log"
|
|
"main/tools"
|
|
"net/http"
|
|
)
|
|
|
|
func CountHandler() http.HandlerFunc {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
var count []byte
|
|
var err error
|
|
if count, err = tools.GetJournalctlLogs("server", "hikan.ru", 24); err != nil {
|
|
log.Printf("%s", err.Error())
|
|
}
|
|
SendCount(w, count)
|
|
})
|
|
}
|
|
|
|
func SendCount(w http.ResponseWriter, data []byte) {
|
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
|
w.WriteHeader(http.StatusOK)
|
|
w.Write(data)
|
|
}
|