'how CloseNotifier interface is implemented by ResponseWriter?

there's a assertion inside ServeHTTP method. the description of CloseNotifier shows as "The CloseNotifier interface is implemented by ResponseWriters" but I dont understand how CloseNotifier implemented by ResponseWriter they are both interface type. for ResponseWrite interface has Header/Write/WriteHeader mthoed defined and for CloseNotifier has only one method CloseNotify in it. any help would be appreciate. thanks! would be good to have detailed explaination in your replies.

func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
    transport := p.Transport
    if transport == nil {
        transport = http.DefaultTransport
    }

    ctx := req.Context()
    if cn, ok := rw.(http.CloseNotifier); ok {  <--here
        var cancel context.CancelFunc
        ctx, cancel = context.WithCancel(ctx)
        defer cancel()
        notifyChan := cn.CloseNotify()
        go func() {
            select {
            case <-notifyChan:
                cancel()
            case <-ctx.Done():
            }
        }()
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source