Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

spindle/config: add abilility to override motd

Signed-off-by: Evan Jarrett <evan@evanjarrett.com>

authored by

Evan Jarrett and committed by tangled.org e9606689 8b4c0280

+21 -3
+21 -3
spindle/server.go
··· 8 8 "log/slog" 9 9 "maps" 10 10 "net/http" 11 + "sync" 11 12 12 13 "github.com/go-chi/chi/v5" 13 14 "tangled.org/core/api/tangled" ··· 31 30 ) 32 31 33 32 //go:embed motd 34 - var motd []byte 33 + var defaultMotd []byte 35 34 36 35 const ( 37 36 rbacDomain = "thisserver" ··· 48 47 cfg *config.Config 49 48 ks *eventconsumer.Consumer 50 49 res *idresolver.Resolver 51 - vault secrets.Manager 50 + vault secrets.Manager 51 + motd []byte 52 + motdMu sync.RWMutex 52 53 } 53 54 54 55 // New creates a new Spindle server with the provided configuration and engines. ··· 131 128 cfg: cfg, 132 129 res: resolver, 133 130 vault: vault, 131 + motd: defaultMotd, 134 132 } 135 133 136 134 err = e.AddSpindle(rbacDomain) ··· 205 201 return s.e 206 202 } 207 203 204 + // SetMotdContent sets custom MOTD content, replacing the embedded default. 205 + func (s *Spindle) SetMotdContent(content []byte) { 206 + s.motdMu.Lock() 207 + defer s.motdMu.Unlock() 208 + s.motd = content 209 + } 210 + 211 + // GetMotdContent returns the current MOTD content. 212 + func (s *Spindle) GetMotdContent() []byte { 213 + s.motdMu.RLock() 214 + defer s.motdMu.RUnlock() 215 + return s.motd 216 + } 217 + 208 218 // Start starts the Spindle server (blocking). 209 219 func (s *Spindle) Start(ctx context.Context) error { 210 220 // starts a job queue runner in the background ··· 264 246 mux := chi.NewRouter() 265 247 266 248 mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 267 - w.Write(motd) 249 + w.Write(s.GetMotdContent()) 268 250 }) 269 251 mux.HandleFunc("/events", s.Events) 270 252 mux.HandleFunc("/logs/{knot}/{rkey}/{name}", s.Logs)