Refactor HTTP control server code

This commit is contained in:
Quentin McGaw
2020-11-05 22:26:53 +00:00
parent 854401a150
commit 7518f74729
4 changed files with 91 additions and 67 deletions

View File

@@ -5,15 +5,15 @@ import (
"net/http"
)
func (s *server) handleGetVersion(w http.ResponseWriter) {
data, err := json.Marshal(s.buildInfo)
func (h *handler) getVersion(w http.ResponseWriter) {
data, err := json.Marshal(h.buildInfo)
if err != nil {
s.logger.Warn(err)
h.logger.Warn(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
if _, err := w.Write(data); err != nil {
s.logger.Warn(err)
h.logger.Warn(err)
w.WriteHeader(http.StatusInternalServerError)
}
}