1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-09-16 09:06:20 +02:00

Merge pull request #356 from stephenafamo/unrwap-writer

Add WrappingResponseWriter interface
This commit is contained in:
Aaron L
2023-11-19 10:11:17 -08:00
committed by GitHub

View File

@@ -95,6 +95,13 @@ type UnderlyingResponseWriter interface {
UnderlyingResponseWriter() http.ResponseWriter
}
// WrappingResponseWriter is a response writer that can be unwrapped
// is is used identically to [UnderlyingResponseWriter] but uses the standard
// set out in [http.ResponseContoller]
type WrappingResponseWriter interface {
Unwrap() http.ResponseWriter
}
// ClientState represents the client's current state and can answer queries
// about it.
type ClientState interface {
@@ -185,6 +192,11 @@ func MustClientStateResponseWriter(w http.ResponseWriter) *ClientStateResponseWr
continue
}
if u, ok := w.(WrappingResponseWriter); ok {
w = u.Unwrap()
continue
}
panic(fmt.Sprintf("ResponseWriter must be a ClientStateResponseWriter or UnderlyingResponseWriter in (see: authboss.LoadClientStateMiddleware): %T", w))
}
}