func compressionFilter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) { // wrap responseWriter into a compressing one compress, err := restful.NewCompressingResponseWriter(resp.ResponseWriter, restful.ENCODING_GZIP) if err != nil { glog.Warningf("Failed to create CompressingResponseWriter for request %q: %v", req.Request.URL, err) return } resp.ResponseWriter = compress defer compress.Close() chain.ProcessFilter(req, resp) }
// Web-service filter function used for request and response logging. func wsLogger(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) { log.Printf(FormatRequestLog(req)) chain.ProcessFilter(req, resp) log.Printf(FormatResponseLog(resp, req)) }