iedc-go/vendor/gopkg.in/chanxuehong/wechat.v2/util/http_response_writer.go
2023-03-03 03:12:15 +08:00

24 lines
438 B
Go

package util
import (
"io"
"net/http"
)
type httpResponseWriter struct {
io.Writer
}
func (httpResponseWriter) Header() http.Header {
return make(map[string][]string)
}
func (httpResponseWriter) WriteHeader(int) {}
// 将 io.Writer 从语义上实现 http.ResponseWriter.
func HttpResponseWriter(w io.Writer) http.ResponseWriter {
if rw, ok := w.(http.ResponseWriter); ok {
return rw
}
return httpResponseWriter{Writer: w}
}