all repos — homestead @ 83369daabc06fafd62316d611baed63fb2900d95

Code for my website

extract and de-duplicate HTTP status capture

Alan Pearce
commit

83369daabc06fafd62316d611baed63fb2900d95

parent

8e31c2454617b413cc672c7561bb512555496927

1 file changed, 19 insertions(+), 0 deletions(-)

changed files
A shared/http/responsewriter.go
@@ -0,0 +1,19 @@
+package http + +import ( + "net/http" +) + +type StatusCapturingResponseWriter struct { + http.ResponseWriter + Status int +} + +func NewStatusCapturingResponseWriter(w http.ResponseWriter) *StatusCapturingResponseWriter { + return &StatusCapturingResponseWriter{w, http.StatusOK} +} + +func (w *StatusCapturingResponseWriter) WriteHeader(code int) { + w.Status = code + w.ResponseWriter.WriteHeader(code) +}