Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(opts ...Option) gin.HandlerFunc
New wraps a handler and aborts the process of the handler if the timeout is reached
Types ¶
type BufferPool ¶ added in v0.0.2
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool represents a pool of buffers. It uses sync.Pool to manage the reuse of buffers, reducing memory allocation and garbage collection overhead.
func (*BufferPool) Get ¶ added in v0.0.2
func (p *BufferPool) Get() *bytes.Buffer
Get returns a buffer from the buffer pool. If the pool is empty, a new buffer is created and returned. This method ensures the reuse of buffers, improving performance.
func (*BufferPool) Put ¶ added in v0.0.2
func (p *BufferPool) Put(buf *bytes.Buffer)
Put adds a buffer back to the pool. This method allows the buffer to be reused in the future, reducing the number of memory allocations.
type Writer ¶ added in v0.0.2
type Writer struct { gin.ResponseWriter // contains filtered or unexported fields }
Writer is a writer with memory buffer
func NewWriter ¶ added in v0.0.2
func NewWriter(w gin.ResponseWriter, buf *bytes.Buffer) *Writer
NewWriter will return a timeout.Writer pointer
func (*Writer) FreeBuffer ¶ added in v0.0.2
func (w *Writer) FreeBuffer()
FreeBuffer will release buffer pointer
func (*Writer) Status ¶ added in v0.0.4
Status we must override Status func here, or the http status code returned by gin.Context.Writer.Status() will always be 200 in other custom gin middlewares.
func (*Writer) WriteHeader ¶ added in v0.0.2
WriteHeader sends an HTTP response header with the provided status code. If the response writer has already written headers or if a timeout has occurred, this method does nothing.
func (*Writer) WriteHeaderNow ¶ added in v1.1.0
func (w *Writer) WriteHeaderNow()
WriteHeaderNow the reason why we override this func is: once calling the func WriteHeaderNow() of based gin.ResponseWriter, this Writer can no longer apply the cached headers to the based gin.ResponseWriter. see test case `TestWriter_WriteHeaderNow` for details.