add test code

This commit is contained in:
2022-09-19 07:47:09 +07:00
parent 8de7cef179
commit cda2e7a2bc
4 changed files with 45 additions and 0 deletions

View File

@@ -12,6 +12,11 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("<h1>Hello World, im ver:"+Version+" !</h1>"))
}
func healthMessage(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/json")
w.Write([]byte(`{"health":"OK"}`))
}
func main() {
port := os.Getenv("PORT")
if port == "" {
@@ -22,5 +27,6 @@ func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", indexHandler)
mux.HandleFunc("/health", healthMessage)
http.ListenAndServe(":"+port, mux)
}