This commit is contained in:
Gerasimos (Makis) Maropoulos 2020-09-07 14:31:19 +03:00
parent b063fbf3c8
commit 4c6568b874
No known key found for this signature in database
GPG Key ID: 5DBE766BD26A54E7
2 changed files with 13 additions and 1 deletions

View File

@ -2717,6 +2717,11 @@ func (ctx *Context) CompressWriter(enable bool) error {
w.Disabled = true w.Disabled = true
case *ResponseRecorder: case *ResponseRecorder:
if enable { if enable {
// If it's a recorder which already wraps the compress, exit.
if _, ok := w.ResponseWriter.(*CompressResponseWriter); ok {
return nil
}
// Keep the Recorder as ctx.writer. // Keep the Recorder as ctx.writer.
// Wrap the existing net/http response writer // Wrap the existing net/http response writer
// with the compressed writer and // with the compressed writer and

View File

@ -114,7 +114,14 @@ func (ac *AccessLog) SetOutput(writers ...io.Writer) *AccessLog {
} }
} }
switch len(writers) {
case 0:
case 1:
ac.Writer = writers[0]
default:
ac.Writer = io.MultiWriter(writers...) ac.Writer = io.MultiWriter(writers...)
}
return ac return ac
} }