MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / UpdateAPI

Method UpdateAPI

internal/api/api.go:88–115  ·  view source on GitHub ↗

UpdateAPI 更新API信息

(c *gin.Context)

Source from the content-addressed store, hash-verified

86
87// UpdateAPI 更新API信息
88func (a *ApiHandler) UpdateAPI(c *gin.Context) {
89 var r req.UpdateApiRequest
90 if err := c.ShouldBindJSON(&r); err != nil {
91 a.l.Error("绑定请求参数失败", zap.Error(err))
92 apiresponse.Error(c)
93 return
94 }
95
96 // 构建更新的API对象
97 api := &domain.Api{
98 ID: r.Id,
99 Name: r.Name,
100 Path: r.Path,
101 Method: r.Method,
102 Description: r.Description,
103 Version: r.Version,
104 Category: r.Category,
105 IsPublic: r.IsPublic,
106 }
107
108 if err := a.svc.UpdateApi(c.Request.Context(), api); err != nil {
109 a.l.Error("更新API失败", zap.Error(err))
110 apiresponse.Error(c)
111 return
112 }
113
114 apiresponse.Success(c)
115}
116
117// DeleteAPI 删除API
118func (a *ApiHandler) DeleteAPI(c *gin.Context) {

Callers

nothing calls this directly

Calls 3

ErrorFunction · 0.92
SuccessFunction · 0.92
UpdateApiMethod · 0.65

Tested by

no test coverage detected