Every example of http Handler that I have seen so far looks like this:
func handleSomeRequest(w http.ResponseWriter, r *http.Request) {
// do something that returns an error
if err != nil {
http.Error(w, "Something bad happened", http.SomeAppropriateStatus)
}
// do other things if there was no error above and finally
w.Write(someBytes)
}
My question is: Assuming there is no point carrying on after "Something bad happened" why don't we just return (after writing someBytes to w inside the if error != nil if that is what is expected). I have never seen any code that returns after calling Error(), and I wonder why.
Thanks for the help.
> Every example of http Handler that I have seen so far looks like this:
Every example of http Handler that I have seen so far looks like this:
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/7a727dd2-e39a-4414-b323-6f3ff2a27aa7n%40googlegroups.com.