restful

package
v0.2.55 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HEADER_AcceptEncoding  = "Accept-Encoding"
	HEADER_ContentEncoding = "Content-Encoding"
	ENCODING_GZIP          = "gzip"
	ENCODING_DEFLATE       = "deflate"
)

Variables

View Source
var EnableContentEncoding = false

OBSOLETE : use restful.DefaultContainer.EnableContentEncoding(true) to change this setting.

Functions

func Decrypt

func Decrypt(passphrase string, ciphertext []byte) ([]byte, error)

func Encrypt

func Encrypt(passphrase, plaintext string) ([]byte, error)

func SetCompressorProvider

func SetCompressorProvider(p CompressorProvider)

SetCompressorProvider sets the actual provider of compressors (zlib or gzip).

Types

type BoundedCachedCompressors

type BoundedCachedCompressors struct {
	// contains filtered or unexported fields
}

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.

func NewBoundedCachedCompressors

func NewBoundedCachedCompressors(writersCapacity, readersCapacity int) *BoundedCachedCompressors

NewBoundedCachedCompressors returns a new, with filled cache, BoundedCachedCompressors.

func (*BoundedCachedCompressors) AcquireGzipReader

func (b *BoundedCachedCompressors) AcquireGzipReader() *gzip.Reader

AcquireGzipReader returns a *gzip.Reader. Needs to be released.

func (*BoundedCachedCompressors) AcquireGzipWriter

func (b *BoundedCachedCompressors) AcquireGzipWriter() *gzip.Writer

AcquireGzipWriter returns an resettable *gzip.Writer. Needs to be released.

func (*BoundedCachedCompressors) AcquireZlibWriter

func (b *BoundedCachedCompressors) AcquireZlibWriter() *zlib.Writer

AcquireZlibWriter returns an resettable *zlib.Writer. Needs to be released.

func (*BoundedCachedCompressors) ReleaseGzipReader

func (b *BoundedCachedCompressors) ReleaseGzipReader(r *gzip.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 (*BoundedCachedCompressors) ReleaseGzipWriter

func (b *BoundedCachedCompressors) ReleaseGzipWriter(w *gzip.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 (*BoundedCachedCompressors) ReleaseZlibWriter

func (b *BoundedCachedCompressors) ReleaseZlibWriter(w *zlib.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.

type CompressingResponseWriter

type CompressingResponseWriter struct {
	// contains filtered or unexported fields
}

CompressingResponseWriter is a http.ResponseWriter that can perform content encoding (gzip and zlib)

func NewCompressingResponseWriter

func NewCompressingResponseWriter(httpWriter http.ResponseWriter, encoding string) (*CompressingResponseWriter, error)

NewCompressingResponseWriter create a CompressingResponseWriter for a known encoding = {gzip,deflate}

func (*CompressingResponseWriter) Close

func (c *CompressingResponseWriter) Close() error

Close the underlying compressor

func (*CompressingResponseWriter) CloseNotify

func (c *CompressingResponseWriter) CloseNotify() <-chan bool

CloseNotify is part of http.CloseNotifier interface

func (*CompressingResponseWriter) Header

Header is part of http.ResponseWriter interface

func (*CompressingResponseWriter) Hijack

Hijack implements the Hijacker interface This is especially useful when combining Container.EnabledContentEncoding in combination with websockets (for instance gorilla/websocket)

func (*CompressingResponseWriter) Write

func (c *CompressingResponseWriter) Write(bytes []byte) (int, error)

Write is part of http.ResponseWriter interface It is passed through the compressor

func (*CompressingResponseWriter) WriteHeader

func (c *CompressingResponseWriter) WriteHeader(status int)

WriteHeader is part of http.ResponseWriter interface

type CompressorProvider

type CompressorProvider interface {
	// Returns a *gzip.Writer which needs to be released later.
	// Before using it, call Reset().
	AcquireGzipWriter() *gzip.Writer

	// Releases an acquired *gzip.Writer.
	ReleaseGzipWriter(w *gzip.Writer)

	// Returns a *gzip.Reader which needs to be released later.
	AcquireGzipReader() *gzip.Reader

	// Releases an acquired *gzip.Reader.
	ReleaseGzipReader(w *gzip.Reader)

	// Returns a *zlib.Writer which needs to be released later.
	// Before using it, call Reset().
	AcquireZlibWriter() *zlib.Writer

	// Releases an acquired *zlib.Writer.
	ReleaseZlibWriter(w *zlib.Writer)
}

CompressorProvider describes a component that can provider compressors for the std methods.

func CurrentCompressorProvider

func CurrentCompressorProvider() CompressorProvider

CurrentCompressorProvider returns the current CompressorProvider. It is initialized using a SyncPoolCompessors.

type SyncPoolCompessors

type SyncPoolCompessors struct {
	GzipWriterPool *sync.Pool
	GzipReaderPool *sync.Pool
	ZlibWriterPool *sync.Pool
}

SyncPoolCompessors is a CompressorProvider that use the standard sync.Pool.

func NewSyncPoolCompessors

func NewSyncPoolCompessors() *SyncPoolCompessors

NewSyncPoolCompessors returns a new ("empty") SyncPoolCompessors.

func (*SyncPoolCompessors) AcquireGzipReader

func (s *SyncPoolCompessors) AcquireGzipReader() *gzip.Reader

func (*SyncPoolCompessors) AcquireGzipWriter

func (s *SyncPoolCompessors) AcquireGzipWriter() *gzip.Writer

func (*SyncPoolCompessors) AcquireZlibWriter

func (s *SyncPoolCompessors) AcquireZlibWriter() *zlib.Writer

func (*SyncPoolCompessors) ReleaseGzipReader

func (s *SyncPoolCompessors) ReleaseGzipReader(r *gzip.Reader)

func (*SyncPoolCompessors) ReleaseGzipWriter

func (s *SyncPoolCompessors) ReleaseGzipWriter(w *gzip.Writer)

func (*SyncPoolCompessors) ReleaseZlibWriter

func (s *SyncPoolCompessors) ReleaseZlibWriter(w *zlib.Writer)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL