(e Encoding)
| 199 | } |
| 200 | |
| 201 | func (enc *Encode) addEncoding(e Encoding) error { |
| 202 | ae := e.AcceptEncoding() |
| 203 | if ae == "" { |
| 204 | return fmt.Errorf("encoder does not specify an Accept-Encoding value") |
| 205 | } |
| 206 | if _, ok := enc.writerPools[ae]; ok { |
| 207 | return fmt.Errorf("encoder already added: %s", ae) |
| 208 | } |
| 209 | if enc.writerPools == nil { |
| 210 | enc.writerPools = make(map[string]*sync.Pool) |
| 211 | } |
| 212 | enc.writerPools[ae] = &sync.Pool{ |
| 213 | New: func() any { |
| 214 | return e.NewEncoder() |
| 215 | }, |
| 216 | } |
| 217 | return nil |
| 218 | } |
| 219 | |
| 220 | // openResponseWriter creates a new response writer that may (or may not) |
| 221 | // encode the response with encodingName. The returned response writer MUST |
no test coverage detected