Skip to content

Commit 4f4ffb4

Browse files
pierre-bclaude
andcommitted
Add version to health endpoint and startup log
- Add Version constant (v1.2) to server package - Include version in /health endpoint response - Log version on server startup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 9109228 commit 4f4ffb4

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [v1.2] - 2025-11-28
6+
7+
### Added
8+
9+
- Version information in `/health` endpoint response: `{"status":"ok","version":"v1.2"}`
10+
- Version logged on server startup: `SelfhostS3 v1.2 starting on :9000`
11+
512
## [v1.1] - 2025-11-28
613

714
### Fixed

internal/server/server.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import (
1515
"github.com/Notifuse/selfhost_s3/internal/storage"
1616
)
1717

18+
// Version is the current version of selfhost_s3
19+
const Version = "v1.2"
20+
1821
// Server represents the SelfhostS3 HTTP server
1922
type Server struct {
2023
config *config.Config
@@ -55,7 +58,7 @@ func (s *Server) Start() error {
5558
mux.HandleFunc("/", s.handleRequest)
5659

5760
addr := fmt.Sprintf(":%d", s.config.Port)
58-
log.Printf("SelfhostS3 starting on %s", addr)
61+
log.Printf("SelfhostS3 %s starting on %s", Version, addr)
5962
log.Printf("Bucket: %s", s.config.Bucket)
6063
log.Printf("Storage path: %s", s.config.StoragePath)
6164

@@ -101,7 +104,7 @@ func (s *Server) corsMiddleware(next http.Handler) http.Handler {
101104
func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) {
102105
w.Header().Set("Content-Type", "application/json")
103106
w.WriteHeader(http.StatusOK)
104-
_, _ = w.Write([]byte(`{"status":"ok"}`))
107+
_, _ = w.Write([]byte(fmt.Sprintf(`{"status":"ok","version":"%s"}`, Version)))
105108
}
106109

107110
// handleRequest routes S3 API requests

internal/server/server_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ func TestHealthEndpoint(t *testing.T) {
171171
}
172172

173173
body, _ := io.ReadAll(resp.Body)
174-
if string(body) != `{"status":"ok"}` {
175-
t.Errorf("expected body {\"status\":\"ok\"}, got %q", string(body))
174+
expectedBody := fmt.Sprintf(`{"status":"ok","version":"%s"}`, Version)
175+
if string(body) != expectedBody {
176+
t.Errorf("expected body %s, got %q", expectedBody, string(body))
176177
}
177178

178179
if resp.Header.Get("Content-Type") != "application/json" {

0 commit comments

Comments
 (0)