add:remove server config func

This commit is contained in:
2026-04-06 03:36:51 +09:00
parent 83aab9d943
commit 9e9134f659
6 changed files with 113 additions and 1 deletions

View File

@@ -69,6 +69,14 @@ func (c *ConfigService) AddServer(name string, s Server) error {
return c.flush()
}
func (c *ConfigService) RemoveServer(name string) error {
if !c.HasServer(name) {
return fmt.Errorf("server %q not found", name)
}
delete(c.servers, name)
return c.flush()
}
func (c *ConfigService) flush() error {
data, err := json.MarshalIndent(c.servers, "", " ")
if err != nil {