...
1 package http
2
3 import (
4 "net/http"
5 )
6
7
8 type TestResponseWriter struct {
9
10
11 StatusCode int
12
13
14 Output string
15
16
17 header http.Header
18 }
19
20
21 func (rw *TestResponseWriter) Header() http.Header {
22
23 if rw.header == nil {
24 rw.header = make(http.Header)
25 }
26
27 return rw.header
28 }
29
30
31 func (rw *TestResponseWriter) Write(bytes []byte) (int, error) {
32
33
34 if rw.StatusCode == 0 {
35 rw.WriteHeader(200)
36 }
37
38
39 rw.Output += string(bytes)
40
41
42 return 0, nil
43
44 }
45
46
47 func (rw *TestResponseWriter) WriteHeader(i int) {
48 rw.StatusCode = i
49 }
50
View as plain text