Yes, I thought about it :).

Did you read the "Why this package exists” section of the README?

The problem with this approach is that an application’s behavior might change 
merely because the method is present. E.g. imagine an application doing this:

```
_, ok := w.(http.Flusher)
if ok {
  w.Write([]byte(“I don’t like talking to flushers!"))
  return
}
```

Perhaps I’m paranoid, but IMO introducing instrumentation into the most 
critical path of a large application is something one should not take too 
lightly. It’s really easy to break some obscure handler somewhere without 
realizing it.

Cheers
Felix

> On 10 Nov 2016, at 14:44, Ian Davis <m...@iandavis.com> wrote:
> 
> 
> On Thu, Nov 10, 2016, at 11:09 AM, Felix Geisendoerfer wrote:
>> I would love for net/http experts to take a look at the "Why this package 
>> exists" section of the README, as well as the horrible hack required to make 
>> things work:
>> 
>> https://github.com/felixge/httpsnoop/blob/master/wrap.go#L44-L163 
>> <https://github.com/felixge/httpsnoop/blob/master/wrap.go#L44-L163>
>> 
>> Please let me know if you have suggestions for simpler approaches and/or 
>> spot any bugs in my implementation.
>> 
> 
> Did you think about performing a type assertion in the rw struct methods like 
> this:
> 
> func (w *rw) Flush() {
>     if f, ok := w.w.(http.Flusher); ok {
>         f.Flush()
>     }
> }
> 
> I haven't tried it myself, but it's what came to mind when reading your Wrap 
> "abomination" (as you call it in the code).
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "golang-nuts" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/golang-nuts/-I5IZgJosYE/unsubscribe 
> <https://groups.google.com/d/topic/golang-nuts/-I5IZgJosYE/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to 
> golang-nuts+unsubscr...@googlegroups.com 
> <mailto:golang-nuts+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to