Redirects are the usual way of telling the client that the content was moved, or there is a needs to look somewhere else to accomplish the request. This recipe describes the way to implement redirects with the standard library.
Handling redirects
How to do it...
- Open the console and create the folder chapter09/recipe09.
- Navigate to the directory.
- Create the file redirect.go with the following content:
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
log.Println("Server is starting...")
http.Handle("/secured/handle",
http.RedirectHandler("/login",
...