Feature: Set and display version info (#63)

* chore: update packages

* feat: show version info

* build: remove ldflags override
This commit is contained in:
Ludvig Lundgren 2022-01-02 15:18:28 +01:00 committed by GitHub
parent c65c7477fd
commit b09796bf7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 50 additions and 15 deletions

View file

@ -14,14 +14,22 @@ type configJson struct {
LogLevel string `json:"log_level"`
LogPath string `json:"log_path"`
BaseURL string `json:"base_url"`
Version string `json:"version"`
Commit string `json:"commit"`
Date string `json:"date"`
}
type configHandler struct {
encoder encoder
server Server
}
func newConfigHandler(encoder encoder) *configHandler {
return &configHandler{encoder: encoder}
func newConfigHandler(encoder encoder, server Server) *configHandler {
return &configHandler{
encoder: encoder,
server: server,
}
}
func (h configHandler) Routes(r chi.Router) {
@ -39,6 +47,9 @@ func (h configHandler) getConfig(w http.ResponseWriter, r *http.Request) {
LogLevel: c.LogLevel,
LogPath: c.LogPath,
BaseURL: c.BaseURL,
Version: h.server.version,
Commit: h.server.commit,
Date: h.server.date,
}
h.encoder.StatusResponse(ctx, w, conf, http.StatusOK)