Not disagreeing or agreeing but just want to mention that Brad's suggested 
solution is not ideal because the a http.ResponseWriter
may implement more interfaces than just http.ResponseWriter. When you wrap 
a response writer with an intercepting response writer, you cannot cast the 
intercepting response writer into the interfaces that the embedded response 
writer implements.

See https://medium.com/@cep21/interface-wrapping-method-erasure-c523b3549912 
for more detail.

On Thursday, November 30, 2017 at 4:03:51 PM UTC-5, Nathan Fisher wrote:
>
> Hi All,
>
> I came across this issue on GitHub relating to 404 handling in which Brad 
> F. said net/http will not implement templating.
>
> https://github.com/golang/go/issues/10707
>
> Perhaps a silly question but why not change http.NotFound into a function 
> pointer like this:
>
> ```
> var NotFound = func(w ResponseWriter, r *Request) {
>   Error(w, "404 page not found", StatusNotFound)
> }
> ```
> This would allow it to be replaced on app start-up via init(), main(), etc.
>
> It seems a quicker and cleaner solution to the boiler plate required for a 
> custom response writer and would maintain backwards compatibility.
>
> The main drawback I see to it would be a nil pointer check (in which case 
> it could default to old behaviour).
>
> Thoughts?
>
> Kind regards,
> Nathan
> -- 
> - sent from my mobile
>

-- 
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