MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / runAction

Method runAction

internal/iplibrary/action_http_api.go:50–81  ·  view source on GitHub ↗
(action string, listType IPListType, item *pb.IPItem)

Source from the content-addressed store, hash-verified

48}
49
50func (this *HTTPAPIAction) runAction(action string, listType IPListType, item *pb.IPItem) error {
51 if item == nil {
52 return nil
53 }
54
55 // TODO 增加节点ID等信息
56 m := maps.Map{
57 "action": action,
58 "listType": listType,
59 "item": maps.Map{
60 "type": item.Type,
61 "ipFrom": item.IpFrom,
62 "ipTo": item.IpTo,
63 "expiredAt": item.ExpiredAt,
64 },
65 }
66 mJSON, err := json.Marshal(m)
67 if err != nil {
68 return err
69 }
70 req, err := http.NewRequest(http.MethodPost, this.config.URL, bytes.NewReader(mJSON))
71 if err != nil {
72 return err
73 }
74 req.Header.Set("User-Agent", teaconst.GlobalProductName+"-Node/"+teaconst.Version)
75 resp, err := httpAPIClient.Do(req)
76 if err != nil {
77 return err
78 }
79 _ = resp.Body.Close()
80 return nil
81}

Callers 2

AddItemMethod · 0.95
DeleteItemMethod · 0.95

Calls 3

DoMethod · 0.80
CloseMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected