

You should get something like thisĪnd watch what gets printed to the terminal, you would notice that some places say “fetching from the cache” while some would be “fetching from the server”. Run them in their respective directories with. To test this out, we have to build both programs - client/main.go and server/main.go. All you have to do to get this functionality is implement RoundTrip :

It is recommended you don’t inspect the response, return an error (nil or non nil) and shouldn’t do stuffs like user auth (or cookies handling). I say this since round tripping occurs before the request is actually sent.Īlthough, it is possible to do anything within the RoundTrip method (as in like middleware for your HTTP handlers),

In lay man terms, it’s like middleware but for an http.Client. This concept I want to talk about is called Round tripping or as the godoc describes it the ability to execute a single HTTP transaction, obtaining the Response for aīasically, what this means is being able to hook into what happens between making an HTTP request and receiving a response. In this post, I would be covering what Round tripping is, it’s applicable usecases and a tiny demo that shows it’s application. And this blog post is just yet another one that talks about another interesting concept in the way Go deals with HTTP and how it makes HTTP related stuffs even much more fun.
