buildRequest builds an http.Request with headers.
(method, path string, body io.Reader)
| 68 | |
| 69 | // buildRequest builds an http.Request with headers. |
| 70 | func (c *ControllerHTTPClient) buildRequest(method, path string, body io.Reader) (req *http.Request, err error) { |
| 71 | path = strings.TrimPrefix(path, "/") |
| 72 | url := fmt.Sprintf("http://%s/%s", c.address, path) |
| 73 | req, err = http.NewRequest(method, url, body) |
| 74 | if err != nil { |
| 75 | req = nil |
| 76 | return |
| 77 | } |
| 78 | |
| 79 | headersCopy := http.Header{} |
| 80 | for k, vs := range c.headers { |
| 81 | for _, v := range vs { |
| 82 | headersCopy.Add(k, v) |
| 83 | } |
| 84 | } |
| 85 | headersCopy.Add("RPC-Procedure", path) |
| 86 | req.Header = headersCopy |
| 87 | return |
| 88 | } |
| 89 | |
| 90 | func (c *ControllerHTTPClient) getResponse(request *http.Request) (respBytes []byte, err error) { |
| 91 | resp, err := c.c.Do(request) |
no test coverage detected