feat: alive UI wave, galaxy presence, spread and fleet enhancements
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
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.
This commit is contained in:
39
server/internal/api/module_handler.go
Normal file
39
server/internal/api/module_handler.go
Normal file
@@ -0,0 +1,39 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user