This repository has been archived on 2022-08-26. You can view files and clone it, but cannot push or open issues or pull requests.
gosocial/pkg/controller/api/version.go

34 lines
727 B
Go
Raw Permalink Normal View History

package api
import (
"encoding/json"
"net/http"
"git.kirsle.net/apps/gosocial/pkg/config"
)
// Version details of the running app.
func Version() http.HandlerFunc {
// Response JSON schema.
type Response struct {
Version string `json:"version"`
Build string `json:"build"`
BuildDate string `json:"buildDate"`
}
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
buf, err := json.Marshal(Response{
Version: config.RuntimeVersion,
Build: config.RuntimeBuild,
BuildDate: config.RuntimeBuildDate,
})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
w.Write(buf)
})
}