package main↵
↵
import (↵
"encoding/json"↵
"log"↵
"net/http"↵
)↵
↵
type status struct {↵
OK bool `json:"ok"`↵
Version string `json:"version"`↵
}↵
↵
func health(w http.ResponseWriter, r *http.Request) {↵
w.Header().Set("Content-Type", "application/json")↵
json.NewEncoder(w).Encode(status{OK: true, Version: "1.4.2"})↵
}↵
↵
func main() {↵
http.HandleFunc("/health", health)↵
log.Fatal(http.ListenAndServe(":8080", nil))↵
}
Click here or press any key to type