MCPcopy
hub / github.com/eolinker/goku_lite / edit

Function edit

console/controller/discovery/edit.go:12–47  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

10)
11
12func edit(w http.ResponseWriter, r *http.Request) {
13
14 if err := r.ParseForm() ; err!= nil{
15 controller.WriteError(w, "260000", "serviceDiscovery", "[param_check] Parse form body error | 解析form表单参数错误", err)
16 return
17 }
18
19 param := new(service.AddParam)
20 err := auto.SetValues(r.PostForm, param)
21 if err != nil {
22 controller.WriteError(w, "260000", "data", fmt.Sprintf("[param_check] %s", err.Error()), err)
23 return
24 }
25
26 d, has := driver2.Get(param.Driver)
27 if !has {
28 controller.WriteError(w, "260000", "data", fmt.Sprintf("[param_check] invalid [driver]"), nil)
29 return
30 }
31
32 if d.Type == driver2.Discovery {
33
34 if param.Config == "" {
35 controller.WriteError(w, "260000", "data", fmt.Sprintf("[param_check] invalid [driver]"), nil)
36 return
37 }
38 }
39
40 err = service.Save(param)
41 if err != nil {
42 controller.WriteError(w, "260000", "data", fmt.Sprintf("[mysql]:%s", err.Error()), err)
43 return
44 }
45
46 controller.WriteResultInfo(w, "serviceDiscovery", "data", nil)
47}

Callers

nothing calls this directly

Calls 5

WriteErrorFunction · 0.92
SaveFunction · 0.92
WriteResultInfoFunction · 0.92
GetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected