mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-20 23:36:38 +00:00
Updates for text streaming functions
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
16
vendor/github.com/openfaas/faas-provider/httputil/write_interceptor.go
generated
vendored
16
vendor/github.com/openfaas/faas-provider/httputil/write_interceptor.go
generated
vendored
@ -7,12 +7,17 @@ import (
|
||||
)
|
||||
|
||||
func NewHttpWriteInterceptor(w http.ResponseWriter) *HttpWriteInterceptor {
|
||||
return &HttpWriteInterceptor{w, 0}
|
||||
return &HttpWriteInterceptor{
|
||||
ResponseWriter: w,
|
||||
statusCode: 0,
|
||||
bytesWritten: 0,
|
||||
}
|
||||
}
|
||||
|
||||
type HttpWriteInterceptor struct {
|
||||
http.ResponseWriter
|
||||
statusCode int
|
||||
statusCode int
|
||||
bytesWritten int64
|
||||
}
|
||||
|
||||
func (c *HttpWriteInterceptor) Status() int {
|
||||
@ -22,6 +27,10 @@ func (c *HttpWriteInterceptor) Status() int {
|
||||
return c.statusCode
|
||||
}
|
||||
|
||||
func (c *HttpWriteInterceptor) BytesWritten() int64 {
|
||||
return c.bytesWritten
|
||||
}
|
||||
|
||||
func (c *HttpWriteInterceptor) Header() http.Header {
|
||||
return c.ResponseWriter.Header()
|
||||
}
|
||||
@ -30,6 +39,9 @@ func (c *HttpWriteInterceptor) Write(data []byte) (int, error) {
|
||||
if c.statusCode == 0 {
|
||||
c.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
c.bytesWritten += int64(len(data))
|
||||
|
||||
return c.ResponseWriter.Write(data)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user