MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / callRequestInterceptor

Method callRequestInterceptor

internal/pluginhost/adapters.go:515–532  ·  view source on GitHub ↗
(ctx context.Context, record capabilityRecord, method string, call func(context.Context, pluginapi.RequestInterceptRequest) (pluginapi.RequestInterceptResponse, error), req pluginapi.RequestInterceptRequest)

Source from the content-addressed store, hash-verified

513}
514
515func (h *Host) callRequestInterceptor(ctx context.Context, record capabilityRecord, method string, call func(context.Context, pluginapi.RequestInterceptRequest) (pluginapi.RequestInterceptResponse, error), req pluginapi.RequestInterceptRequest) (out pluginapi.RequestInterceptResponse, ok bool) {
516 if h == nil || call == nil || h.isPluginFused(record.id) || !h.recordCurrent(record) {
517 return pluginapi.RequestInterceptResponse{}, false
518 }
519 defer func() {
520 if recovered := recover(); recovered != nil {
521 h.fusePlugin(record.id, method, recovered)
522 out = pluginapi.RequestInterceptResponse{}
523 ok = false
524 }
525 }()
526 resp, errIntercept := call(ctx, req)
527 if errIntercept != nil {
528 log.Warnf("pluginhost: request interceptor %s failed: %v", record.id, errIntercept)
529 return pluginapi.RequestInterceptResponse{}, false
530 }
531 return resp, true
532}
533
534func (h *Host) callResponseInterceptor(ctx context.Context, record capabilityRecord, interceptor pluginapi.ResponseInterceptor, req pluginapi.ResponseInterceptRequest) (out pluginapi.ResponseInterceptResponse, ok bool) {
535 if h == nil || interceptor == nil || h.isPluginFused(record.id) || !h.recordCurrent(record) {

Callers 1

interceptRequestMethod · 0.95

Calls 3

isPluginFusedMethod · 0.95
recordCurrentMethod · 0.95
fusePluginMethod · 0.95

Tested by

no test coverage detected