What is the proper way to handle drupal_get_destination and drupal_goto? I am considering the following approach in my controller (the method which corresponds to a given route).

$destination = \Drupal::destination()-&gt;getAsArray();
if (isset($destination['destination'])) {
  return new RedirectResponse(Url::fromUri($destination['destination']));
}
else {
  return $this-&gt;redirect('acquia_connector.settings');
}


Should I use different code to handle both route based and URL based redirects?
Drupal automatically uses destination, you don't have to do anything. If a destination argument is given, it will override default. So you can simplify your code to a simple, hardcoded $this->redirect(...).

The only exception is when you have links that you want to respect destination too (e.g. a cancel link on a confirm form), then you have to do it yourself. But the default confirm form already does that too AFAIK.