Added /version endpoint #37

Merged
robin merged 4 commits from dev into main 2026-09-01 17:16:53 +02:00
Showing only changes of commit 62a5324e6d - Show all commits
+11 -2
View File
@@ -6,15 +6,24 @@ import (
"github.com/robindittmar/dttmr-api/internal/api/response"
)
type Version struct {
type VersionResponse struct {
Version string `json:"version"`
Commit string `json:"commit"`
BuildTime string `json:"buildTime"`
}
// VersionHandler handles the version route
//
// @Summary Service version
// @Description Reports the version of the API
// @Tags Version
// @Accept json
// @Produce json
// @Success 200 {object} VersionResponse
// @Router /version [get]
func VersionHandler(version string, commit string, buildTime string) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
response.JSON(r.Context(), w, http.StatusOK, Version{
response.JSON(r.Context(), w, http.StatusOK, VersionResponse{
Version: version,
Commit: commit,
BuildTime: buildTime,