(c *routing.Context)
| 169 | } |
| 170 | |
| 171 | func generateInvokeRequest(c *routing.Context) *api.InvokeProxyRequest { |
| 172 | hMap := make(map[string]string) |
| 173 | c.Request.Header.VisitAll(func(key, value []byte) { |
| 174 | hMap[string(key)] = string(value) |
| 175 | }) |
| 176 | body, err := generateBodyStream(c) |
| 177 | if err != nil { |
| 178 | logs.Errorf("generate body stream failed: %s", err) |
| 179 | // TODO: error? |
| 180 | return api.NewInvokeProxyRequest(hMap, nil, nil) |
| 181 | } |
| 182 | invokeType := strings.ToLower(string(c.Request.Header.Peek(api.HeaderInvokeType))) |
| 183 | if invokeType == api.InvokeTypeEvent { |
| 184 | bodyBytes, _ := ioutil.ReadAll(body) |
| 185 | return api.NewInvokeProxyRequest(hMap, bodyBytes, nil) |
| 186 | } |
| 187 | return api.NewInvokeProxyRequest(hMap, nil, body) |
| 188 | } |
| 189 | |
| 190 | func generateBodyStream(c *routing.Context) (body *bufio.ReadWriter, err error) { |
| 191 | bodyBuffer := bytes.NewBuffer(nil) |
no test coverage detected