code: func (a *authenticator) loginHandler(w http.ResponseWriter, req *http.Request) {
  	// GET returns login page. Submit redirects to authenticate.
  	if req.Method == http.MethodGet {
  		r := render.New(render.Options{
  			Directory:  "templates",
  			Asset:      Asset,
  			AssetNames: AssetNames,
  		})
  		r.HTML(w, http.StatusOK, "login", nil)
  	} else {
  		// POST decodes provided credentials
  		credentials := &credentials{}
  		decoder := json.NewDecoder(req.Body)
  		err := decoder.Decode(&credentials)
  		if err != nil {
  			errStr := fmt.Sprintf("500 internal server error: failed to decode json: %v", err)
  			a.formatter.Text(w, http.StatusInternalServerError, errStr)
  			return
  		}
  		token, errCode, err := a.getTokenFor(credentials)
  		if err != nil {
  			a.formatter.Text(w, errCode, err.Error())
  			return
  		}
  
  		// Returns token string.
  		a.formatter.Text(w, http.StatusOK, token)
  	}
  }
docs: // Login handler shows simple page to log in