Implement web API foundation
Add application container, Gin router, graceful shutdown handler, and version endpoint. This establishes the skeleton for the WebDisk HTTP API as described in the architecture. - Add internal/app/WebApp for runtime dependencies and version - Add internal/server/router with GET /api/v1/version route - Add graceful shutdown runner with signal handling in cmd/serve - Add internal/api/ErrorResponse for standard HTTP error body - Update roadmap, architecture, and decisions documentation
This commit is contained in:
27
internal/handler/version.go
Normal file
27
internal/handler/version.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// VersionResponse is the response body for the version endpoint.
|
||||
type VersionResponse struct {
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// VersionHandler serves application version metadata.
|
||||
type VersionHandler struct {
|
||||
version string
|
||||
}
|
||||
|
||||
// NewVersionHandler creates a version handler.
|
||||
func NewVersionHandler(appVersion string) *VersionHandler {
|
||||
return &VersionHandler{version: appVersion}
|
||||
}
|
||||
|
||||
// Get writes the current application version.
|
||||
func (h *VersionHandler) Get(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, VersionResponse{Version: h.version})
|
||||
}
|
||||
Reference in New Issue
Block a user