go.mod: update to github.com/emicklei/go-restful/v3 v3.7.3
full diff: https://github.com/emicklei/go-restful/compare/v2.9.5...v3.7.3 - Switch to using go modules - Add check for wildcard to fix CORS filter - Add check on writer to prevent compression of response twice - Add OPTIONS shortcut WebService receiver - Add Route metadata to request attributes or allow adding attributes to routes - Add wroteHeader set - Enable content encoding on Handle and ServeHTTP - Feat: support google custom verb - Feature: override list of method allowed without content-type - Fix Allow header not set on '405: Method Not Allowed' responses - Fix Go 1.15: conversion from int to string yields a string of one rune - Fix WriteError return value - Fix: use request/response resulting from filter chain - handle path params with prefixes and suffixes - HTTP response body was broken, if struct to be converted to JSON has boolean value - List available representations in 406 body - Support describing response headers - Unwrap function in filter chain + remove unused dispatchWithFilters Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
		
							
								
								
									
										103
									
								
								vendor/github.com/emicklei/go-restful/v3/compressor_cache.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								vendor/github.com/emicklei/go-restful/v3/compressor_cache.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,103 @@ | ||||
| package restful | ||||
|  | ||||
| // Copyright 2015 Ernest Micklei. All rights reserved. | ||||
| // Use of this source code is governed by a license | ||||
| // that can be found in the LICENSE file. | ||||
|  | ||||
| import ( | ||||
| 	"compress/gzip" | ||||
| 	"compress/zlib" | ||||
| ) | ||||
|  | ||||
| // BoundedCachedCompressors is a CompressorProvider that uses a cache with a fixed amount | ||||
| // of writers and readers (resources). | ||||
| // If a new resource is acquired and all are in use, it will return a new unmanaged resource. | ||||
| type BoundedCachedCompressors struct { | ||||
| 	gzipWriters     chan *gzip.Writer | ||||
| 	gzipReaders     chan *gzip.Reader | ||||
| 	zlibWriters     chan *zlib.Writer | ||||
| 	writersCapacity int | ||||
| 	readersCapacity int | ||||
| } | ||||
|  | ||||
| // NewBoundedCachedCompressors returns a new, with filled cache,  BoundedCachedCompressors. | ||||
| func NewBoundedCachedCompressors(writersCapacity, readersCapacity int) *BoundedCachedCompressors { | ||||
| 	b := &BoundedCachedCompressors{ | ||||
| 		gzipWriters:     make(chan *gzip.Writer, writersCapacity), | ||||
| 		gzipReaders:     make(chan *gzip.Reader, readersCapacity), | ||||
| 		zlibWriters:     make(chan *zlib.Writer, writersCapacity), | ||||
| 		writersCapacity: writersCapacity, | ||||
| 		readersCapacity: readersCapacity, | ||||
| 	} | ||||
| 	for ix := 0; ix < writersCapacity; ix++ { | ||||
| 		b.gzipWriters <- newGzipWriter() | ||||
| 		b.zlibWriters <- newZlibWriter() | ||||
| 	} | ||||
| 	for ix := 0; ix < readersCapacity; ix++ { | ||||
| 		b.gzipReaders <- newGzipReader() | ||||
| 	} | ||||
| 	return b | ||||
| } | ||||
|  | ||||
| // AcquireGzipWriter returns an resettable *gzip.Writer. Needs to be released. | ||||
| func (b *BoundedCachedCompressors) AcquireGzipWriter() *gzip.Writer { | ||||
| 	var writer *gzip.Writer | ||||
| 	select { | ||||
| 	case writer, _ = <-b.gzipWriters: | ||||
| 	default: | ||||
| 		// return a new unmanaged one | ||||
| 		writer = newGzipWriter() | ||||
| 	} | ||||
| 	return writer | ||||
| } | ||||
|  | ||||
| // ReleaseGzipWriter accepts a writer (does not have to be one that was cached) | ||||
| // only when the cache has room for it. It will ignore it otherwise. | ||||
| func (b *BoundedCachedCompressors) ReleaseGzipWriter(w *gzip.Writer) { | ||||
| 	// forget the unmanaged ones | ||||
| 	if len(b.gzipWriters) < b.writersCapacity { | ||||
| 		b.gzipWriters <- w | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // AcquireGzipReader returns a *gzip.Reader. Needs to be released. | ||||
| func (b *BoundedCachedCompressors) AcquireGzipReader() *gzip.Reader { | ||||
| 	var reader *gzip.Reader | ||||
| 	select { | ||||
| 	case reader, _ = <-b.gzipReaders: | ||||
| 	default: | ||||
| 		// return a new unmanaged one | ||||
| 		reader = newGzipReader() | ||||
| 	} | ||||
| 	return reader | ||||
| } | ||||
|  | ||||
| // ReleaseGzipReader accepts a reader (does not have to be one that was cached) | ||||
| // only when the cache has room for it. It will ignore it otherwise. | ||||
| func (b *BoundedCachedCompressors) ReleaseGzipReader(r *gzip.Reader) { | ||||
| 	// forget the unmanaged ones | ||||
| 	if len(b.gzipReaders) < b.readersCapacity { | ||||
| 		b.gzipReaders <- r | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // AcquireZlibWriter returns an resettable *zlib.Writer. Needs to be released. | ||||
| func (b *BoundedCachedCompressors) AcquireZlibWriter() *zlib.Writer { | ||||
| 	var writer *zlib.Writer | ||||
| 	select { | ||||
| 	case writer, _ = <-b.zlibWriters: | ||||
| 	default: | ||||
| 		// return a new unmanaged one | ||||
| 		writer = newZlibWriter() | ||||
| 	} | ||||
| 	return writer | ||||
| } | ||||
|  | ||||
| // ReleaseZlibWriter accepts a writer (does not have to be one that was cached) | ||||
| // only when the cache has room for it. It will ignore it otherwise. | ||||
| func (b *BoundedCachedCompressors) ReleaseZlibWriter(w *zlib.Writer) { | ||||
| 	// forget the unmanaged ones | ||||
| 	if len(b.zlibWriters) < b.writersCapacity { | ||||
| 		b.zlibWriters <- w | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Sebastiaan van Stijn
					Sebastiaan van Stijn