func (b *BufferWriter) Close() error {
	return b.W.Close()
}
Close close the writer
package utils
import (
	"bufio"
	"fmt"
	"io"
	"net"
	"net/http"
	"net/url"
	"reflect"
	log "github.com/sirupsen/logrus"
)
type ProxyWriter struct {
	w      http.ResponseWriter
	code   int
	length int64
	log *log.Logger
}
func NewProxyWriter(w http.ResponseWriter) *ProxyWriter {
	return NewProxyWriterWithLogger(w, log.StandardLogger())
}
func NewProxyWriterWithLogger(w http.ResponseWriter, l *log.Logger) *ProxyWriter {
	return &ProxyWriter{
		w:   w,
		log: l,
	}
}
func (p *ProxyWriter) StatusCode() int {
	if p.code == 0 {
		return http.StatusOK
	}
	return p.code
}
func (p *ProxyWriter) GetLength() int64 {
	return p.length
}
func (p *ProxyWriter) Header() http.Header {
	return p.w.Header()
}
func (p *ProxyWriter) Write(buf []byte) (int, error) {
	p.length = p.length + int64(len(buf))
	return p.w.Write(buf)
}
func (p *ProxyWriter) WriteHeader(code int) {
	p.code = code
	p.w.WriteHeader(code)
}
func (p *ProxyWriter) Flush() {
	if f, ok := p.w.(http.Flusher); ok {
		f.Flush()
	}
}
func (p *ProxyWriter) CloseNotify() <-chan bool {
	if cn, ok := p.w.(http.CloseNotifier); ok {
		return cn.CloseNotify()
	}
	p.log.Debugf("Upstream ResponseWriter of type %v does not implement http.CloseNotifier. Returning dummy channel.", reflect.TypeOf(p.w))
	return make(<-chan bool)
}
func (p *ProxyWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
	if hi, ok := p.w.(http.Hijacker); ok {
		return hi.Hijack()
	}
	p.log.Debugf("Upstream ResponseWriter of type %v does not implement http.Hijacker. Returning dummy channel.", reflect.TypeOf(p.w))
	return nil, nil, fmt.Errorf("the response writer that was wrapped in this proxy, does not implement http.Hijacker. It is of type: %v", reflect.TypeOf(p.w))
}
func NewBufferWriter(w io.WriteCloser) *BufferWriter {
	return &BufferWriter{
		W: w,
		H: make(http.Header),
	}
}
type BufferWriter struct {
	H    http.Header
	Code int
	W    io.WriteCloser
}