File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,17 @@ import (
7
7
"testing"
8
8
)
9
9
10
+ type codeRecorder struct {
11
+ http.ResponseWriter
12
+
13
+ code int
14
+ }
15
+
16
+ func (w * codeRecorder ) WriteHeader (code int ) {
17
+ w .ResponseWriter .WriteHeader (code )
18
+ w .code = code
19
+ }
20
+
10
21
func ExampleProxy (t * testing.T ) {
11
22
ca , err := loadCA ()
12
23
if err != nil {
@@ -17,8 +28,10 @@ func ExampleProxy(t *testing.T) {
17
28
CA : & ca ,
18
29
Wrap : func (upstream http.Handler ) http.Handler {
19
30
return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
31
+ cr := & codeRecorder {ResponseWriter : w }
20
32
log .Println ("Got Content-Type:" , r .Header .Get ("Content-Type" ))
21
- upstream .ServeHTTP (w , r )
33
+ upstream .ServeHTTP (cr , r )
34
+ log .Println ("Got Status:" , cr .code )
22
35
})
23
36
},
24
37
}
You can’t perform that action at this time.
0 commit comments