Documentation
¶
Index ¶
- Variables
- func BufferPool() *bpool.SizedBufferPool
- func Chain(handlers ...http.HandlerFunc) http.Handler
- func ChainLinkWrap(wrapper ChainerFunc, handlers ...http.HandlerFunc) http.Handler
- func EnableTrace(e bool) bool
- func HttpScopedBPHandlerWriter(handler http.Handler) http.Handler
- func HttpScopedBufferHandler(handler http.Handler) http.Handler
- func HttpScopedHandlerWriter(handler http.Handler) http.Handler
- func Recover(next http.Handler) http.Handler
- func RecoverFunc(next http.HandlerFunc) http.HandlerFunc
- func TraceEnvConfig() bool
- func Tracer() *trace.Tracer
- type Buffer
- type BufferWriter
- func (bf *BufferWriter) BPFlushAll()
- func (bf *BufferWriter) Body() []byte
- func (bf *BufferWriter) BodyString() string
- func (bf *BufferWriter) FlushAll()
- func (bf *BufferWriter) FlushCode()
- func (bf *BufferWriter) FlushHeaders()
- func (bf *BufferWriter) HasChanged() bool
- func (bf *BufferWriter) Header() http.Header
- func (bf *BufferWriter) IsOk() bool
- func (bf *BufferWriter) Reset()
- func (bf *BufferWriter) Write(b []byte) (int, error)
- func (bf *BufferWriter) WriteHeader(i int)
- type ChainerFunc
Constants ¶
This section is empty.
Variables ¶
var BP *bpool.SizedBufferPool
var BPAlloc = 16384
var BPSize = 32
var NoOp = http.HandlerFunc(func(http.ResponseWriter, *http.Request) {
defer tracer.Enable(enable).ScopedTrace()()
})
Functions ¶
func BufferPool ¶
func BufferPool() *bpool.SizedBufferPool
func Chain ¶
func Chain(handlers ...http.HandlerFunc) http.Handler
Chain creates an ordered chain of handlers from an argument list The handlers call chain A->B->C => R(A)->R(B)->R(C)
func ChainLinkWrap ¶
func ChainLinkWrap(wrapper ChainerFunc, handlers ...http.HandlerFunc) http.Handler
ChainLinkWrap wraps each handler in the argument list of handlers The handlers call chain A->B->C => R(A->B->C)
func EnableTrace ¶
func HttpScopedBPHandlerWriter ¶
use a buffer buffer pools buffer then write/flush the buffer to the ResponseWriter.
func HttpScopedHandlerWriter ¶
use a bytes.Buffer then write/flush the buffer to the ResponseWriter
func RecoverFunc ¶
func RecoverFunc(next http.HandlerFunc) http.HandlerFunc
Types ¶
type BufferWriter ¶
type BufferWriter struct {
// ResponseWriter is the underlying response writer that is wrapped
// by BufferWriter
http.ResponseWriter
// BufferWriter is the underlying io.Writer that buffers the response
// body
Buffer *bytes.Buffer
// Code is the cached status code
Code int
// contains filtered or unexported fields
}
Buffer is a ResponseWriter wrapper that may be used as buffer.
func NewBufferPoolWriter ¶
func NewBufferPoolWriter(w http.ResponseWriter) (bf *BufferWriter)
NewBufferPoolWriter returns a BufferWriter wrapping the given response writer.
func NewBufferWriter ¶
func NewBufferWriter(w http.ResponseWriter) (bf *BufferWriter)
NewBufferWriter returns a BufferWriter wrapping the given response writer.
func (*BufferWriter) BPFlushAll ¶
func (bf *BufferWriter) BPFlushAll()
FlushAll flushes headers, status code and body to the underlying ResponseWriter, if something changed
func (*BufferWriter) Body ¶
func (bf *BufferWriter) Body() []byte
Body returns the bytes of the underlying buffer (that is meant to be the body of the response)
func (*BufferWriter) BodyString ¶
func (bf *BufferWriter) BodyString() string
BodyString returns the string of the underlying buffer (that is meant to be the body of the response)
func (*BufferWriter) FlushAll ¶
func (bf *BufferWriter) FlushAll()
FlushAll flushes headers, status code and body to the underlying ResponseWriter, if something changed
func (*BufferWriter) FlushCode ¶
func (bf *BufferWriter) FlushCode()
FlushCode flushes the status code to the underlying responsewriter if it was set.
func (*BufferWriter) FlushHeaders ¶
func (bf *BufferWriter) FlushHeaders()
FlushHeaders adds the headers to the underlying ResponseWriter, removing them from BufferWriter.
func (*BufferWriter) HasChanged ¶
func (bf *BufferWriter) HasChanged() bool
HasChanged returns true if Header, WriteHeader or Write has been called
func (*BufferWriter) Header ¶
func (bf *BufferWriter) Header() http.Header
Header returns the cached http.Header and tracks this call as change
func (*BufferWriter) IsOk ¶
func (bf *BufferWriter) IsOk() bool
IsOk returns true if the cached status code is not set or in the 2xx range.
func (*BufferWriter) Reset ¶
func (bf *BufferWriter) Reset()
Reset set the BufferWriter to the defaults
func (*BufferWriter) Write ¶
func (bf *BufferWriter) Write(b []byte) (int, error)
Write writes to the underlying buffer and tracks this call as change
func (*BufferWriter) WriteHeader ¶
func (bf *BufferWriter) WriteHeader(i int)
WriteHeader writes the cached status code and tracks this call as change