HTTP control server /version endpoint

This commit is contained in:
Quentin McGaw
2020-11-04 14:07:04 +00:00
parent b5fb2b849a
commit 3b04677f8f
6 changed files with 55 additions and 21 deletions

View File

@@ -0,0 +1,19 @@
package server
import (
"encoding/json"
"net/http"
)
func (s *server) handleGetVersion(w http.ResponseWriter) {
data, err := json.Marshal(s.buildInfo)
if err != nil {
s.logger.Warn(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
if _, err := w.Write(data); err != nil {
s.logger.Warn(err)
w.WriteHeader(http.StatusInternalServerError)
}
}