Skip to content

Commit 8fc0b1f

Browse files
authored
Merge pull request #356 from stephenafamo/unrwap-writer
Add WrappingResponseWriter interface
2 parents 16b99bb + 12fc261 commit 8fc0b1f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

client_state.go

+12
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ type UnderlyingResponseWriter interface {
9595
UnderlyingResponseWriter() http.ResponseWriter
9696
}
9797

98+
// WrappingResponseWriter is a response writer that can be unwrapped
99+
// is is used identically to [UnderlyingResponseWriter] but uses the standard
100+
// set out in [http.ResponseContoller]
101+
type WrappingResponseWriter interface {
102+
Unwrap() http.ResponseWriter
103+
}
104+
98105
// ClientState represents the client's current state and can answer queries
99106
// about it.
100107
type ClientState interface {
@@ -185,6 +192,11 @@ func MustClientStateResponseWriter(w http.ResponseWriter) *ClientStateResponseWr
185192
continue
186193
}
187194

195+
if u, ok := w.(WrappingResponseWriter); ok {
196+
w = u.Unwrap()
197+
continue
198+
}
199+
188200
panic(fmt.Sprintf("ResponseWriter must be a ClientStateResponseWriter or UnderlyingResponseWriter in (see: authboss.LoadClientStateMiddleware): %T", w))
189201
}
190202
}

0 commit comments

Comments
 (0)