(ctx context.Context, req pluginapi.RequestInterceptRequest, method string, invoke func(pluginapi.RequestInterceptor, context.Context, pluginapi.RequestInterceptRequest) (pluginapi.RequestInterceptResponse, error), skipPluginID string)
| 590 | } |
| 591 | |
| 592 | func (h *Host) interceptRequest(ctx context.Context, req pluginapi.RequestInterceptRequest, method string, invoke func(pluginapi.RequestInterceptor, context.Context, pluginapi.RequestInterceptRequest) (pluginapi.RequestInterceptResponse, error), skipPluginID string) pluginapi.RequestInterceptResponse { |
| 593 | current := pluginapi.RequestInterceptResponse{ |
| 594 | Headers: cloneHeader(req.Headers), |
| 595 | Body: bytes.Clone(req.Body), |
| 596 | } |
| 597 | skipPluginID = strings.TrimSpace(skipPluginID) |
| 598 | for _, record := range h.activeRecords() { |
| 599 | interceptor := record.plugin.Capabilities.RequestInterceptor |
| 600 | if h.isPluginFused(record.id) || interceptor == nil || record.id == skipPluginID { |
| 601 | continue |
| 602 | } |
| 603 | nextReq := req |
| 604 | nextReq.Headers = cloneHeader(current.Headers) |
| 605 | nextReq.Body = bytes.Clone(current.Body) |
| 606 | nextReq.Metadata = cloneInterceptorMetadata(req.Metadata) |
| 607 | if resp, ok := h.callRequestInterceptor(ctx, record, method, func(callCtx context.Context, callReq pluginapi.RequestInterceptRequest) (pluginapi.RequestInterceptResponse, error) { |
| 608 | return invoke(interceptor, callCtx, callReq) |
| 609 | }, nextReq); ok { |
| 610 | current.Headers = mergeHeaders(current.Headers, resp.Headers, resp.ClearHeaders) |
| 611 | if len(resp.Body) > 0 { |
| 612 | current.Body = bytes.Clone(resp.Body) |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | return current |
| 617 | } |
| 618 | |
| 619 | func (h *Host) InterceptResponse(ctx context.Context, req pluginapi.ResponseInterceptRequest) pluginapi.ResponseInterceptResponse { |
| 620 | return h.InterceptResponseExcept(ctx, req, "") |
no test coverage detected