MCPcopy
hub / github.com/keploy/keploy / IsPassThrough

Function IsPassThrough

utils/utils.go:183–219  ·  view source on GitHub ↗
(logger *zap.Logger, req *http.Request, destPort uint, opts models.OutgoingOptions)

Source from the content-addressed store, hash-verified

181}
182
183func IsPassThrough(logger *zap.Logger, req *http.Request, destPort uint, opts models.OutgoingOptions) bool {
184 passThrough := false
185
186 for _, bypass := range opts.Rules {
187 if bypass.Host != "" {
188 regex, err := regexp.Compile(bypass.Host)
189 if err != nil {
190 LogError(logger, err, "failed to compile the host regex", zap.Any("metadata", GetReqMeta(req)))
191 continue
192 }
193 passThrough = regex.MatchString(req.Host)
194 if !passThrough {
195 continue
196 }
197 }
198 if bypass.Path != "" {
199 regex, err := regexp.Compile(bypass.Path)
200 if err != nil {
201 LogError(logger, err, "failed to compile the path regex", zap.Any("metadata", GetReqMeta(req)))
202 continue
203 }
204 passThrough = regex.MatchString(req.URL.String())
205 if !passThrough {
206 continue
207 }
208 }
209
210 if passThrough {
211 if bypass.Port == 0 || bypass.Port == destPort {
212 return true
213 }
214 passThrough = false
215 }
216 }
217
218 return passThrough
219}
220
221func kebabToCamel(s string) string {
222 parts := strings.Split(s, "-")

Callers 3

parseFinalHTTPMethod · 0.92
buildHTTPMockMethod · 0.92
IsFilteredFunction · 0.92

Calls 3

LogErrorFunction · 0.85
GetReqMetaFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected