// Filter out only requests with the given response status code func StatusIs(status int) goproxy.RespCondition { return goproxy.RespConditionFunc( func(resp *http.Response, ctx *goproxy.ProxyCtx) bool { if resp == nil { return false } return resp.StatusCode == status }) }
// True for any text/* content type except a couple // specific exceptions that generally indicate things // we don't care about (css/js/json) func TextButNotCode() goproxy.RespCondition { return goproxy.RespConditionFunc( func(resp *http.Response, ctx *goproxy.ProxyCtx) bool { contentType := resp.Header.Get("Content-Type") if !strings.HasPrefix(contentType, "text/") { return false } r := strings.HasPrefix(contentType, "text/css") || strings.HasPrefix(contentType, "text/javascript") || strings.HasPrefix(contentType, "text/json") return !r }) }