FAQ
So I want to make sure that all errors from my go app have a simple json
content-type and format. There are some places within net/http where Errors
are sent, so it looks like my options are to either replace http.Error with
my own method or intercept errors downstream and rewrite them as json if
they aren't in that format already.

So my question is, without modifying the standard packages, is there a way
to replace the http.Error method with my own?



--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Anmol Sethi at Jun 4, 2016 at 3:45 pm
    https://gist.github.com/nhooyr/076c397a761fefded1e580c837c528ea
    On Jun 4, 2016, at 1:01 AM, CJ Ess wrote:

    So I want to make sure that all errors from my go app have a simple json content-type and format. There are some places within net/http where Errors are sent, so it looks like my options are to either replace http.Error with my own method or intercept errors downstream and rewrite them as json if they aren't in that format already.

    So my question is, without modifying the standard packages, is there a way to replace the http.Error method with my own?



    --
    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+unsubscribe@googlegroups.com.
    For more options, visit 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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Msilverlock at Jun 7, 2016 at 6:13 pm
    http://elithrar.github.io/article/http-handler-error-handling-revisited/


    On Saturday, June 4, 2016 at 7:30:16 AM UTC-7, CJ Ess wrote:

    So I want to make sure that all errors from my go app have a simple json
    content-type and format. There are some places within net/http where Errors
    are sent, so it looks like my options are to either replace http.Error with
    my own method or intercept errors downstream and rewrite them as json if
    they aren't in that format already.

    So my question is, without modifying the standard packages, is there a way
    to replace the http.Error method with my own?

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJun 4, '16 at 2:30p
activeJun 7, '16 at 6:13p
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase