1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00
echo/response.go
Vishal Rana 6633a1fca7 New renderer interface #21
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-04-09 14:59:31 -07:00

50 lines
736 B
Go

package echo
import (
"log"
"net/http"
)
type (
response struct {
Writer http.ResponseWriter
status int
size int
committed bool
}
)
func (r *response) Header() http.Header {
return r.Writer.Header()
}
func (r *response) WriteHeader(n int) {
if r.committed {
// TODO: Warning
log.Println("echo: response already committed")
return
}
r.status = n
r.Writer.WriteHeader(n)
r.committed = true
}
func (r *response) Write(b []byte) (n int, err error) {
n, err = r.Writer.Write(b)
r.size += n
return n, err
}
func (r *response) Status() int {
return r.status
}
func (r *response) Size() int {
return r.size
}
func (r *response) reset(w http.ResponseWriter) {
r.Writer = w
r.committed = false
}