Skip to content
This repository was archived by the owner on Feb 7, 2018. It is now read-only.

Commit 6eee0f0

Browse files
author
Arthur White
committed
Fix ResponseStatus from pointer of unknown type
1 parent ed1d13c commit 6eee0f0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

httputil/response.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ func ResponseStatus(w http.ResponseWriter) int {
3838

3939
// httpResponseStruct returns the response structure after going trough all the intermediary response writers.
4040
func httpResponseStruct(v reflect.Value) reflect.Value {
41-
switch v.Type().String() {
42-
case "*http.response":
43-
return v.Elem()
44-
default:
45-
return httpResponseStruct(v.FieldByName("ResponseWriter").Elem())
41+
if v.Kind() == reflect.Ptr {
42+
v = v.Elem()
4643
}
44+
45+
if v.Type().String() == "http.response" {
46+
return v
47+
}
48+
49+
return httpResponseStruct(v.FieldByName("ResponseWriter").Elem())
4750
}
4851

4952
// SetDetectedContentType detects, sets and returns the response Conten-Type header value.

0 commit comments

Comments
 (0)