MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / generateInvokeRequest

Function generateInvokeRequest

pkg/controller/handler.go:171–188  ·  view source on GitHub ↗
(c *routing.Context)

Source from the content-addressed store, hash-verified

169}
170
171func 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
190func generateBodyStream(c *routing.Context) (body *bufio.ReadWriter, err error) {
191 bodyBuffer := bytes.NewBuffer(nil)

Callers 1

InvokeHandlerMethod · 0.85

Calls 3

ErrorfFunction · 0.92
NewInvokeProxyRequestFunction · 0.92
generateBodyStreamFunction · 0.85

Tested by

no test coverage detected