apiPatchConfig handles PATCH /admin/api/v1/clibridge-config.
(r *http.Request)
| 48 | |
| 49 | // apiPatchConfig handles PATCH /admin/api/v1/clibridge-config. |
| 50 | func (m *CLIBridgeModule) apiPatchConfig(r *http.Request) (int, bool, any) { |
| 51 | var body struct { |
| 52 | Enabled *bool `json:"Enabled"` |
| 53 | AllowedTools []string `json:"AllowedTools"` |
| 54 | AllowedPaths []string `json:"AllowedPaths"` |
| 55 | } |
| 56 | |
| 57 | if err := json.NewDecoder(r.Body).Decode(&body); err != nil { |
| 58 | return http.StatusBadRequest, false, "malformed request body: " + err.Error() |
| 59 | } |
| 60 | |
| 61 | if body.Enabled != nil { |
| 62 | val := "false" |
| 63 | if *body.Enabled { |
| 64 | val = "true" |
| 65 | } |
| 66 | _ = configs.SetVal("Modules.clibridge.Enabled", val) |
| 67 | } |
| 68 | |
| 69 | lc := listConfig{ |
| 70 | AllowedTools: body.AllowedTools, |
| 71 | AllowedPaths: body.AllowedPaths, |
| 72 | } |
| 73 | if err := m.saveListConfig(lc); err != nil { |
| 74 | return http.StatusInternalServerError, false, "failed to save config: " + err.Error() |
| 75 | } |
| 76 | |
| 77 | return http.StatusOK, true, "saved" |
| 78 | } |
nothing calls this directly
no test coverage detected