Changeset 0.12.0 (#63)

This commit is contained in:
2026-02-25 21:38:49 +00:00
parent c9d8e9457e
commit 88216ec4cb
59 changed files with 13115 additions and 139 deletions

View File

@@ -0,0 +1,62 @@
package handlers
import (
"net/http"
"github.com/gin-gonic/gin"
"git.gobha.me/xcaliber/chat-switchboard/storage"
)
// storageConfigured is a package-level flag set during init.
// Read by PublicSettings to include in the boot payload.
var storageConfigured bool
// SetStorageConfigured sets the package-level flag indicating whether
// file storage is available. Called from main.go after storage init.
func SetStorageConfigured(configured bool) {
storageConfigured = configured
}
// StorageHandler handles file storage admin endpoints.
type StorageHandler struct {
store storage.ObjectStore
}
// NewStorageHandler creates a StorageHandler.
// store may be nil if storage is not configured.
func NewStorageHandler(store storage.ObjectStore) *StorageHandler {
return &StorageHandler{store: store}
}
// Configured returns true if a storage backend is available.
func (h *StorageHandler) Configured() bool {
return h.store != nil
}
// Status returns storage backend status and statistics.
//
// GET /admin/storage/status
func (h *StorageHandler) Status(c *gin.Context) {
if h.store == nil {
c.JSON(http.StatusOK, gin.H{
"backend": "none",
"configured": false,
"healthy": false,
})
return
}
stats, err := h.store.Stats(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"error": "failed to collect storage stats",
"backend": h.store.Backend(),
"configured": true,
"healthy": false,
})
return
}
c.JSON(http.StatusOK, stats)
}