MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / online

Method online

module/system-apikey/iml.go:285–321  ·  view source on GitHub ↗
(ctx context.Context, client gateway.IClientDriver)

Source from the content-addressed store, hash-verified

283}
284
285func (i *imlAPIKeyModule) online(ctx context.Context, client gateway.IClientDriver) error {
286
287 // 获取所有apikey
288 list, err := i.apikeyService.Search(ctx, "", nil, "create_at desc")
289 if err != nil {
290 return err
291 }
292 app := &gateway.ApplicationRelease{
293 BasicItem: &gateway.BasicItem{
294 ID: "apipark-global",
295 Description: "apipark global consumer",
296 Version: time.Now().Format("20060102150405"),
297 },
298 Authorizations: utils.SliceToSlice(list, func(a *system_apikey.APIKey) *gateway.Authorization {
299 authCfg := map[string]interface{}{
300 "apikey": utils.Md5(a.Value),
301 }
302 return &gateway.Authorization{
303 Type: "apikey",
304 Position: "header",
305 TokenName: "Authorization",
306 Expire: a.Expired,
307 Config: authCfg,
308 HideCredential: true,
309 Label: map[string]string{
310 "authorization": a.Id,
311 "authorization_name": a.Name,
312 },
313 }
314 }),
315 }
316 err = client.Application().Online(ctx, app)
317 if err != nil {
318 return err
319 }
320 return nil
321}
322
323func (i *imlAPIKeyModule) initGateway(ctx context.Context, clusterId string, clientDriver gateway.IClientDriver) error {
324 return i.online(ctx, clientDriver)

Callers 4

CreateMethod · 0.95
UpdateMethod · 0.95
DeleteMethod · 0.95
initGatewayMethod · 0.95

Calls 3

SearchMethod · 0.65
OnlineMethod · 0.65
ApplicationMethod · 0.65

Tested by

no test coverage detected