ResponseWriter: Add TLS and Conn methods
This commit is contained in:
parent
75abb99518
commit
d35dd3d867
15
response.go
15
response.go
@ -126,6 +126,7 @@ type ResponseWriter struct {
|
||||
mediatype string
|
||||
wroteHeader bool
|
||||
bodyAllowed bool
|
||||
conn net.Conn
|
||||
}
|
||||
|
||||
// NewResponseWriter returns a ResponseWriter that uses the provided io.WriteCloser.
|
||||
@ -207,3 +208,17 @@ func (w *ResponseWriter) Flush() error {
|
||||
func (w *ResponseWriter) Close() error {
|
||||
return w.closer.Close()
|
||||
}
|
||||
|
||||
// Conn returns the underlying network connection.
|
||||
func (w *ResponseWriter) Conn() net.Conn {
|
||||
return w.conn
|
||||
}
|
||||
|
||||
// TLS returns information about the underlying TLS connection.
|
||||
func (w *ResponseWriter) TLS() *tls.ConnectionState {
|
||||
if tlsConn, ok := w.conn.(*tls.Conn); ok {
|
||||
state := tlsConn.ConnectionState()
|
||||
return &state
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user