How can net/http get to net.conn?

  golang, question

golang

func IndexHandler(w http.ResponseWriter, r *http.Request) {
 fmt.Fprintln(w, "hello world", r.RemoteAddr)
 }

Usehttp.Hijacker:

package main
 
 import (
 "fmt"
 "log"
 "net/http"
 )
 
 func IndexHandler(w http.ResponseWriter, r *http.Request) {
 e, ok := w.(http.Hijacker)
 if !  ok {
 return
 }
 
 conn, _, err := e.Hijack()
 if err !  = nil {
 ...
 }
 defer conn.Close()
 }
 
 func main() {
 http.HandleFunc("/", IndexHandler)
 if err := http.ListenAndServe(":8070", nil);   err !  = nil {
 log.Fatal(err)
 }
 }