func notifyProxyEvent(action string, req *http.Request, events chan longpolling.Event) { // in the event localhost isn't added to noproxy, don't emit localhost event normUrl := strings.ToLower(req.URL.String()) if strings.HasPrefix(normUrl, "http://127.0.0.1:") || strings.HasPrefix(normUrl, "http://127.0.0.1/") || strings.HasPrefix(normUrl, "127.0.0.1:") || strings.HasPrefix(normUrl, "127.0.0.1/") { // no events for you! return } var category string if referer := req.Header.Get("Referer"); len(referer) > 0 { category = utils.StripProxyExceptionStringFromUrl(referer) } else { category = utils.StripProxyExceptionStringFromUrl(req.URL.String()) } event := longpolling.Event{time.Now(), category, action + ": " + req.URL.String()} events <- event }
func notifyProxyEvent(action string, req *http.Request, lpManager *golongpoll.LongpollManager) { // in the event localhost isn't added to noproxy, don't emit localhost event normUrl := strings.ToLower(req.URL.String()) if strings.HasPrefix(normUrl, "http://127.0.0.1:") || strings.HasPrefix(normUrl, "http://127.0.0.1/") || strings.HasPrefix(normUrl, "127.0.0.1:") || strings.HasPrefix(normUrl, "127.0.0.1/") { // no events for you! return } var category string if referer := req.Header.Get("Referer"); len(referer) > 0 { category = utils.StripProxyExceptionStringFromUrl(referer) } else { category = utils.StripProxyExceptionStringFromUrl(req.URL.String()) } eventData := action + ": " + req.URL.String() if err := lpManager.Publish(category, eventData); err != nil { log.Printf("ERROR: failed to publish event. error: %q", err) } }