go-tower: first release v0.1.0

This commit is contained in:
2026-02-14 14:02:21 +00:00
parent 93a16c3665
commit 3576d420d2
13 changed files with 753 additions and 1 deletions

33
response_writer.go Normal file
View File

@@ -0,0 +1,33 @@
package tower
import "net/http"
type responseWriter struct {
http.ResponseWriter
status int
wroteHeader bool
}
func (w *responseWriter) WriteHeader(code int) {
if !w.wroteHeader {
w.status = code
w.wroteHeader = true
}
w.ResponseWriter.WriteHeader(code)
}
func (w *responseWriter) Write(b []byte) (int, error) {
if !w.wroteHeader {
w.WriteHeader(http.StatusOK)
}
return w.ResponseWriter.Write(b)
}
func (w *responseWriter) Status() int {
if w.status == 0 {
return http.StatusOK
}
return w.status
}