mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-20 23:26:34 +00:00
Fix issue with provider metrics
https://github.com/openfaas/faas-provider/pull/66 Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
11
vendor/github.com/openfaas/faas-provider/httputil/write_interceptor.go
generated
vendored
11
vendor/github.com/openfaas/faas-provider/httputil/write_interceptor.go
generated
vendored
@ -12,14 +12,14 @@ func NewHttpWriteInterceptor(w http.ResponseWriter) *HttpWriteInterceptor {
|
||||
|
||||
type HttpWriteInterceptor struct {
|
||||
http.ResponseWriter
|
||||
StatusCode int
|
||||
statusCode int
|
||||
}
|
||||
|
||||
func (c *HttpWriteInterceptor) Status() int {
|
||||
if c.StatusCode == 0 {
|
||||
if c.statusCode == 0 {
|
||||
return http.StatusOK
|
||||
}
|
||||
return c.StatusCode
|
||||
return c.statusCode
|
||||
}
|
||||
|
||||
func (c *HttpWriteInterceptor) Header() http.Header {
|
||||
@ -27,11 +27,14 @@ func (c *HttpWriteInterceptor) Header() http.Header {
|
||||
}
|
||||
|
||||
func (c *HttpWriteInterceptor) Write(data []byte) (int, error) {
|
||||
if c.statusCode == 0 {
|
||||
c.WriteHeader(http.StatusOK)
|
||||
}
|
||||
return c.ResponseWriter.Write(data)
|
||||
}
|
||||
|
||||
func (c *HttpWriteInterceptor) WriteHeader(code int) {
|
||||
c.StatusCode = code
|
||||
c.statusCode = code
|
||||
c.ResponseWriter.WriteHeader(code)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user