1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-31 16:57:04 +00:00
This commit is contained in:
Gerasimos Maropoulos
2016-07-25 14:45:12 +03:00
parent 3ee38a363c
commit d10273391a
4 changed files with 19 additions and 15 deletions

15
iris.go
View File

@@ -199,10 +199,7 @@ func New(cfg ...config.Iris) *Framework {
// we always use 's' no 'f' because 's' is easier for me to remember because of 'station'
// some things never change :)
s := &Framework{
Config: &c,
gzipWriterPool: sync.Pool{New: func() interface{} {
return &gzip.Writer{}
}},
Config: &c,
responses: &responseEngines{},
Available: make(chan bool),
}
@@ -852,7 +849,15 @@ func (s *Framework) URL(routeName string, args ...interface{}) (url string) {
// Note that: each iris station has its own pool
// see ReleaseGzip
func (s *Framework) AcquireGzip(w io.Writer) *gzip.Writer {
gzipWriter := s.gzipWriterPool.Get().(*gzip.Writer)
v := s.gzipWriterPool.Get()
if v == nil {
gzipWriter, err := gzip.NewWriterLevel(w, gzip.DefaultCompression)
if err != nil {
return nil
}
return gzipWriter
}
gzipWriter := v.(*gzip.Writer)
gzipWriter.Reset(w)
return gzipWriter
}