package server import ( "encoding/json" "log" "net/http" ) func (s *Server) HelloWorldHandler(w http.ResponseWriter, r *http.Request) { resp := make(map[string]string) resp["message"] = "Hello World" jsonResp, err := json.Marshal(resp) if err != nil { log.Fatalf("error handling JSON marshal. Err: %v", err) } _, _ = w.Write(jsonResp) } func (s *Server) healthHandler(w http.ResponseWriter, r *http.Request) { jsonResp, err := json.Marshal(s.db.Health()) if err != nil { log.Fatalf("error handling JSON marshal. Err: %v", err) } // set header to application/json w.Header().Set("Content-Type", "application/json") // encode the response _, _ = w.Write(jsonResp) }