Files
AetherForge/server/internal/api/module_handler.go
AetherForge a32860b0d9
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
feat: alive UI wave, galaxy presence, spread and fleet enhancements
Dashboard ambient layer, comrade presence, Mission Deck and War Room, Emberwake supply chain, spread/docs publishing, fleet policy and modules API, CI docker mining, and refreshed USB pack.
2026-06-04 22:36:17 -07:00

40 lines
861 B
Go

package api
import (
"net/http"
"github.com/go-chi/chi/v5"
)
type ModuleHandler struct {
store *ModuleStore
}
func NewModuleHandler(store *ModuleStore) *ModuleHandler {
return &ModuleHandler{store: store}
}
// GetAgentModule serves signed module JSON to forged agents (X-Fleet-Secret).
func (h *ModuleHandler) GetAgentModule(w http.ResponseWriter, r *http.Request) {
name := chi.URLParam(r, "name")
m, err := h.store.Get(name)
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
writeJSON(w, m)
}
// ListModules lists available packs for the dashboard.
func (h *ModuleHandler) ListModules(w http.ResponseWriter, r *http.Request) {
mods, err := h.store.List()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if mods == nil {
mods = []ModuleManifest{}
}
writeJSON(w, mods)
}