MCPcopy
hub / github.com/koderover/zadig / TestConnection

Function TestConnection

pkg/microservice/aslan/core/system/handler/proxy.go:205–239  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

203}
204
205func TestConnection(c *gin.Context) {
206 ctx, err := internalhandler.NewContextWithAuthorization(c)
207 defer func() { internalhandler.JSONResponse(c, ctx) }()
208
209 if err != nil {
210
211 ctx.RespErr = fmt.Errorf("authorization Info Generation failed: err %s", err)
212 ctx.UnAuthorized = true
213 return
214 }
215
216 args := new(commonmodels.Proxy)
217 data, err := c.GetRawData()
218 if err != nil {
219 log.Errorf("TestConnection c.GetRawData() err : %v", err)
220 }
221 if err = json.Unmarshal(data, args); err != nil {
222 log.Errorf("TestConnection json.Unmarshal err : %v", err)
223 }
224
225 c.Request.Body = io.NopCloser(bytes.NewBuffer(data))
226
227 if err := c.ShouldBindWith(&args, binding.JSON); err != nil {
228 ctx.RespErr = e.ErrInvalidParam.AddDesc("invalid proxy args")
229 return
230 }
231
232 // authorization checks
233 if !ctx.Resources.IsSystemAdmin {
234 ctx.UnAuthorized = true
235 return
236 }
237
238 ctx.RespErr = service.TestConnection(args, ctx.Logger)
239}

Callers

nothing calls this directly

Calls 4

ErrorfFunction · 0.92
TestConnectionFunction · 0.92
AddDescMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected