dynamic redirect(String url, {int code: 301})

Redirects to user to the given URL.

Source

redirect(String url, {int code: 301}) {
  header(HttpHeaders.LOCATION, url);
  status(code ?? 301);
  write('''
  <!DOCTYPE html>
  <html>
    <head>
      <title>Redirecting...</title>
      <meta http-equiv="refresh" content="0; url=$url">
    </head>
    <body>
      <h1>Currently redirecting you...</h1>
      <br />
      Click <a href="$url"></a> if you are not automatically redirected...
      <script>
        window.location = "$url";
      </script>
    </body>
  </html>
  ''');
  end();
}