| 107 | } |
| 108 | |
| 109 | func (c *ControllerClient) ListRuntimes() ([]*rtctrl.RuntimeInfo, error) { |
| 110 | rts := make([]*rtctrl.RuntimeInfo, 0) |
| 111 | req := fasthttp.AcquireRequest() |
| 112 | p := fmt.Sprintf("%s://%s/%s/runtimes", c.scheme, c.host, c.version) |
| 113 | req.SetRequestURI(p) |
| 114 | |
| 115 | req.Header.SetHost(c.host) |
| 116 | req.Header.SetMethod("GET") |
| 117 | req.Header.SetContentType("application/json") |
| 118 | resp, err := c.client.Do(req) |
| 119 | if err != nil { |
| 120 | logs.Errorf("unexpected minikun client error: %s", err) |
| 121 | // TODO: handler unexpected error |
| 122 | return nil, err |
| 123 | } |
| 124 | err = json.Unmarshal(resp.Body(), &rts) |
| 125 | if err != nil { |
| 126 | logs.Errorf("json unmarshal err :%v", err) |
| 127 | return nil, err |
| 128 | } |
| 129 | return rts, nil |
| 130 | } |