Documentation
¶
Overview ¶
Package sheepcounter is a byte counter that wraps a http.ResponseWriter
Index ¶
- Variables
- type SheepCounter
- func (sc *SheepCounter) Counter() int64
- func (sc *SheepCounter) Counter2() (int64, error)
- func (sc *SheepCounter) Flush()
- func (sc *SheepCounter) Header() http.Header
- func (sc *SheepCounter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (sc *SheepCounter) Reset()
- func (sc *SheepCounter) ResponseWriter() http.ResponseWriter
- func (sc *SheepCounter) UCounter() uint64
- func (sc *SheepCounter) UCounter2() (uint64, error)
- func (sc *SheepCounter) Write(data []byte) (int, error)
- func (sc *SheepCounter) WriteHeader(statusCode int)
Constants ¶
This section is empty.
Variables ¶
var New = NewSheepCounter
New is an alias for the NewSheepCounter function
Functions ¶
This section is empty.
Types ¶
type SheepCounter ¶
type SheepCounter struct {
// contains filtered or unexported fields
}
SheepCounter is a struct that both wraps and implements a http.ResponseWriter
func NewSheepCounter ¶
func NewSheepCounter(w http.ResponseWriter) *SheepCounter
NewSheepCounter creates a struct that wraps an existing http.ResponseWriter
func (*SheepCounter) Counter ¶
func (sc *SheepCounter) Counter() int64
Counter returns the bytes written so far, as an int64. May return a negative number if the counter has overflown math.MaxInt64. Use Counter2() or UCounter2() instead if you wish to catch any overflow that may happen.
func (*SheepCounter) Counter2 ¶ added in v1.5.0
func (sc *SheepCounter) Counter2() (int64, error)
Counter2 returns the bytes written so far, as an int64. An error is returned if the counter has overflown.
func (*SheepCounter) Flush ¶ added in v1.6.2
func (sc *SheepCounter) Flush()
Flush implements the http.Flusher interface and tries to flush the data.
func (*SheepCounter) Header ¶
func (sc *SheepCounter) Header() http.Header
Header helps fulfill the http.ResponseWriter interface
func (*SheepCounter) Hijack ¶ added in v1.2.0
func (sc *SheepCounter) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack helps fulfill the http.Hijacker interface
func (*SheepCounter) ResponseWriter ¶ added in v1.3.0
func (sc *SheepCounter) ResponseWriter() http.ResponseWriter
ReponseWriter returns a pointer to the wrapped http.ResponseWriter
func (*SheepCounter) UCounter ¶ added in v1.6.0
func (sc *SheepCounter) UCounter() uint64
UCounter returns the bytes written so far, as an uint64
func (*SheepCounter) UCounter2 ¶ added in v1.6.0
func (sc *SheepCounter) UCounter2() (uint64, error)
UCounter2 returns the bytes written so far, as an int64. An error is returned if the counter has overflown.
func (*SheepCounter) Write ¶
func (sc *SheepCounter) Write(data []byte) (int, error)
Write helps fulfill the http.ResponseWriter interface, while also recording the written bytes
func (*SheepCounter) WriteHeader ¶
func (sc *SheepCounter) WriteHeader(statusCode int)
WriteHeader helps fulfill the http.ResponseWriter interface