( activeApp core.App, baseEvent *core.RequestEvent, ir *core.InternalRequest, infoContext string, optNext func(data any) error, )
| 273 | } |
| 274 | |
| 275 | func processInternalRequest( |
| 276 | activeApp core.App, |
| 277 | baseEvent *core.RequestEvent, |
| 278 | ir *core.InternalRequest, |
| 279 | infoContext string, |
| 280 | optNext func(data any) error, |
| 281 | ) (*BatchRequestResult, error) { |
| 282 | handle, params, ok := prepareInternalAction(activeApp, ir, optNext) |
| 283 | if !ok { |
| 284 | return nil, errors.New("unknown batch request action") |
| 285 | } |
| 286 | |
| 287 | // construct a new http.Request |
| 288 | // --------------------------------------------------------------- |
| 289 | buf, mw, err := multipartDataFromInternalRequest(ir) |
| 290 | if err != nil { |
| 291 | return nil, err |
| 292 | } |
| 293 | |
| 294 | r, err := http.NewRequest(strings.ToUpper(ir.Method), ir.URL, buf) |
| 295 | if err != nil { |
| 296 | return nil, err |
| 297 | } |
| 298 | |
| 299 | // cleanup multipart temp files |
| 300 | defer func() { |
| 301 | if r.MultipartForm != nil { |
| 302 | if err := r.MultipartForm.RemoveAll(); err != nil { |
| 303 | activeApp.Logger().Warn("failed to cleanup temp batch files", "error", err) |
| 304 | } |
| 305 | } |
| 306 | }() |
| 307 | |
| 308 | // load batch request path params |
| 309 | // --- |
| 310 | for k, v := range params { |
| 311 | r.SetPathValue(k, v) |
| 312 | } |
| 313 | |
| 314 | // clone original request |
| 315 | // --- |
| 316 | r.RequestURI = r.URL.RequestURI() |
| 317 | r.Proto = baseEvent.Request.Proto |
| 318 | r.ProtoMajor = baseEvent.Request.ProtoMajor |
| 319 | r.ProtoMinor = baseEvent.Request.ProtoMinor |
| 320 | r.Host = baseEvent.Request.Host |
| 321 | r.RemoteAddr = baseEvent.Request.RemoteAddr |
| 322 | r.TLS = baseEvent.Request.TLS |
| 323 | |
| 324 | if s := baseEvent.Request.TransferEncoding; s != nil { |
| 325 | s2 := make([]string, len(s)) |
| 326 | copy(s2, s) |
| 327 | r.TransferEncoding = s2 |
| 328 | } |
| 329 | |
| 330 | if baseEvent.Request.Trailer != nil { |
| 331 | r.Trailer = baseEvent.Request.Trailer.Clone() |
| 332 | } |
no test coverage detected
searching dependent graphs…