I would write a type that wraps the request and implements LogValuer. Then 
you would log the request as

     logger.Debug("req", "r", requestWrapper{r})

On Thursday, July 27, 2023 at 10:01:27 AM UTC-4 Jens-Uwe Mager wrote:

> I am trying to convert some older code to slog and I am running into the 
> issue that if some data structure contains http.Request I get the message:
>
> {"time":"2023-07-27T15:49:04.744214+02:00","level":"DEBUG","msg":"req","r":"!ERROR:json:
>  
> unsupported type: func() (io.ReadCloser, error)"}
>
> So I believed it would be a good idea to add a LogValue() function to 
> http.Request that used httputil.DumpRequest(), but that does not work as I 
> cannot add methods from my code. Any good idea to approach that?
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/64cac638-52a5-43ea-a68b-73544bf3fad7n%40googlegroups.com.

Reply via email to