How it works...

The net/http package exposes a DefaultClient package variable, which is used by the following internal operations: Do, GET, POST, and so on. Our Setup() function returns a client and sets the default client to be the same client. When setting up a client, most of your modifications will take place in the transport, which only needs to implement the RoundTripper interface.

This recipe gives an example of a no-op round tripper that always returns a 418 status code. You can imagine how this might be useful for testing. It also demonstrates passing in clients as function arguments, using them as structure parameters, and using the default client to process requests.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.206.169