only respond to GET request
This commit is contained in:
parent
a0c2a0c584
commit
bb32647830
1 changed files with 7 additions and 4 deletions
11
main.go
11
main.go
|
@ -28,14 +28,18 @@ func parseAndRenderTemplate(templateLocation string, data interface{}) (string,
|
|||
var config scanner.Config = scanner.LoadConfig()
|
||||
|
||||
func rootPage(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "GET" {
|
||||
return
|
||||
}
|
||||
|
||||
// get service status'
|
||||
var data []scanner.ServiceStatus
|
||||
for _, v := range config.Service {
|
||||
data=append(data, scanner.TestService(v))
|
||||
data = append(data, scanner.TestService(v))
|
||||
}
|
||||
|
||||
|
||||
log.Printf("%v", data)
|
||||
|
||||
|
||||
parsedTemplate, err := parseAndRenderTemplate("templates/index.html.mustache", data)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
|
@ -47,7 +51,6 @@ func rootPage(w http.ResponseWriter, r *http.Request) {
|
|||
func main() {
|
||||
http.HandleFunc("/", rootPage)
|
||||
|
||||
|
||||
fmt.Printf("Listening on http://%v/\n", "localhost:3333")
|
||||
log.Fatal(http.ListenAndServe(":3333", nil))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue