aboutsummaryrefslogtreecommitdiff
path: root/response.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-23 20:59:04 -0500
committerAdnan Maolood <[email protected]>2021-02-23 20:59:04 -0500
commitd35dd3d8676dba18986e2704316a77371bd4a002 (patch)
tree34590f1801ced31ce5255855b4b6cbf2f996accc /response.go
parentrequest: Remove TLS and Conn methods (diff)
downloadgo-gemini-d35dd3d8676dba18986e2704316a77371bd4a002.tar.xz
go-gemini-d35dd3d8676dba18986e2704316a77371bd4a002.zip
ResponseWriter: Add TLS and Conn methods
Diffstat (limited to 'response.go')
-rw-r--r--response.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/response.go b/response.go
index abbc757..57807e7 100644
--- a/response.go
+++ b/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
+}