gotsrpc/responsewriter.go
2021-05-21 15:25:09 +02:00

25 lines
368 B
Go

package gotsrpc
import (
"net/http"
)
type ResponseWriter struct {
http.ResponseWriter
wroteHeader bool
status int
}
func (r *ResponseWriter) WriteHeader(status int) {
r.status = status
r.wroteHeader = true
r.ResponseWriter.WriteHeader(status)
}
func (r *ResponseWriter) Status() int {
if !r.wroteHeader {
return http.StatusOK
}
return r.status
}