Last active
March 21, 2017 08:07
-
-
Save simcap/8e333aed7c5af7e4865352e866cba124 to your computer and use it in GitHub Desktop.
Prez- Collectors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c *Collector) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
limitReader := http.MaxBytesReader(w, r.Body, c.MaxPayloadSize) | |
payload, err := ioutil.ReadAll(limitReader) | |
if err != nil { | |
w.WriteHeader(http.StatusInternalServerError) | |
if IsIgnorableError(err) { | |
return | |
} | |
log.Printf("read body from %s: %s\n%s", err, RemoteAddr(r), payload) | |
return | |
} | |
defer limitReader.Close() | |
event, err := c.GetEvent(payload) | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment