Use cases for custom ResponseWriter

304 views
Skip to first unread message

Amit Saha

unread,
Mar 16, 2021, 10:14:06 PM3/16/21
to golang-nuts
Hi all,

I came across the need for writing a custom ResponseWriter when I
wanted to log the response status code.

Is there any other use case where this is needed to implement one?
Thanks and appreciate any pointers.

Best Regards,
Amit.

Gregor Best

unread,
Mar 17, 2021, 4:41:09 AM3/17/21
to Amit Saha, golang-nuts

net/http/httptest contains an implementation of http.ResponseWriter that's used for testing request handlers in isolation (without spinning up a server).

-- 
Gregor Best
  be...@pferdewetten.de

Amnon

unread,
Mar 17, 2021, 5:54:06 AM3/17/21
to golang-nuts

https://github.com/gorilla/handlers
contains a number of ResponseWriters to provide functions such as compression and logging

Amit Saha

unread,
Mar 18, 2021, 6:50:39 AM3/18/21
to Amnon, golang-nuts
On Wed, Mar 17, 2021 at 8:54 PM Amnon <amn...@gmail.com> wrote:
>
>
> https://github.com/gorilla/handlers
> contains a number of ResponseWriters to provide functions such as compression and logging
> On Wednesday, 17 March 2021 at 08:41:09 UTC be...@pferdewetten.de wrote:
>>
>> net/http/httptest contains an implementation of http.ResponseWriter that's used for testing request handlers in isolation (without spinning up a server).

Thanks both of you!

>>
>> On 17.03.21 03:12, Amit Saha wrote:
>>
>> Hi all,
>>
>> I came across the need for writing a custom ResponseWriter when I
>> wanted to log the response status code.
>>
>> Is there any other use case where this is needed to implement one?
>> Thanks and appreciate any pointers.
>>
>> Best Regards,
>> Amit.
>>
>> --
>> Gregor Best
>> be...@pferdewetten.de
>
> --
> 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/5261f1fb-5bba-4c11-b650-304aea20427cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages