code: func (a *authenticator) authenticationHandler(w http.ResponseWriter, req *http.Request) {
  	// Read name and password from the form (if accessed from browser)
  	credentials := &credentials{
  		Username: req.FormValue("name"),
  		Password: req.FormValue("password"),
  	}
  	token, errCode, err := a.getTokenFor(credentials)
  	if err != nil {
  		a.formatter.Text(w, errCode, err.Error())
  		return
  	}
  	// Writes cookie with token.
  	http.SetCookie(w, &http.Cookie{
  		Name:   cookieName,
  		Path:   "/",
  		MaxAge: int(a.expTime.Seconds()),
  		Value:  token,
  		Secure: false,
  	})
  	// Automatically move to index page.
  	target := "/"
  	http.Redirect(w, req, target, http.StatusMovedPermanently)
  }
docs: // Authentication handler verifies credentials from login page (GET) and writes cookie with token