code: func (rd *Redirector) wrapCallback(fn func(http.ResponseWriter, *http.Request) (*auth.SSHLoginResponse, error)) http.Handler {
  	clone := *rd.proxyURL
  	clone.Path = "/web/msg/error/login_failed"
  	errorURL := clone.String()
  	clone.Path = "/web/msg/info/login_success"
  	successURL := clone.String()
  
  	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  		response, err := fn(w, r)
  		if err != nil {
  			if trace.IsNotFound(err) {
  				http.NotFound(w, r)
  				return
  			}
  			select {
  			case rd.errorC <- err:
  			case <-rd.context.Done():
  				http.Redirect(w, r, errorURL, http.StatusFound)
  				return
  			}
  			http.Redirect(w, r, errorURL, http.StatusFound)
  			return
  		}
  		select {
  		case rd.responseC <- response:
  		case <-rd.context.Done():
  			http.Redirect(w, r, errorURL, http.StatusFound)
  			return
  		}
  		http.Redirect(w, r, successURL, http.StatusFound)
  	})
  }
docs: // wrapCallback is a helper wrapper method that wraps callback HTTP handler
  // and sends a result to the channel and redirect users to error page