In some cases, you need more control over how redirects are handled. This recipe will show you the mechanism which the Go client implements so that you have more control over handling HTTP redirects.
Handling HTTP redirects
How to do it...
- Open the console and create the folder chapter07/recipe08.
- Navigate to the directory.
- Create the redirects.go file with the following content:
package main
import (
"fmt"
"net/http"
)
const addr = "localhost:7070"
type RedirecServer struct {
redirectCount int
}
func (s *RedirecServer) ServeHTTP(rw http.ResponseWriter,
req *http.Request) {
...