MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / persistLocked

Method persistLocked

internal/api/handlers/management/handler.go:408–422  ·  view source on GitHub ↗

persistLocked saves the current in-memory config to disk. It expects the caller to hold h.mu.

(c *gin.Context)

Source from the content-addressed store, hash-verified

406// persistLocked saves the current in-memory config to disk.
407// It expects the caller to hold h.mu.
408func (h *Handler) persistLocked(c *gin.Context) bool {
409 // Preserve comments when writing
410 if err := config.SaveConfigPreserveComments(h.configFilePath, h.cfg); err != nil {
411 c.JSON(http.StatusInternalServerError, gin.H{"error": fmt.Sprintf("failed to save config: %v", err)})
412 return false
413 }
414 snapshot := h.reloadSnapshotConfigLocked()
415 c.JSON(http.StatusOK, gin.H{"status": "ok"})
416 var reqCtx context.Context
417 if c != nil && c.Request != nil {
418 reqCtx = c.Request.Context()
419 }
420 h.reloadConfigAfterManagementSaveAsync(reqCtx, snapshot)
421 return true
422}
423
424// Helper methods for simple types
425func (h *Handler) updateBoolField(c *gin.Context, set func(bool)) {

Callers 15

persistMethod · 0.95
PutGeminiKeysMethod · 0.95
PatchGeminiKeyMethod · 0.95
DeleteGeminiKeyMethod · 0.95
PutClaudeKeysMethod · 0.95
PatchClaudeKeyMethod · 0.95
DeleteClaudeKeyMethod · 0.95
PutOpenAICompatMethod · 0.95
PatchOpenAICompatMethod · 0.95
DeleteOpenAICompatMethod · 0.95
PutVertexCompatKeysMethod · 0.95
PatchVertexCompatKeyMethod · 0.95

Calls 4

ContextMethod · 0.80

Tested by

no test coverage detected