docs: def redirect(endpoint, **kw):
      """
      Redirect allow to redirect dynamically using the classes methods without
      knowing the right endpoint.
      Expecting all endpoint have GET as method, it will try to pick the first
      match, based on the endpoint provided or the based on the Rule map_url
  
      An endpoint can also be passed along with **kw
  
      An http: or https: can also be passed, and will redirect to that site.
  
      example:
          redirect(self.hello_world)
          redirect(self.other_page, name="x", value="v")
          redirect("https://google.com")
          redirect(views.ContactPage.index)
      :param endpoint:
      :return: redirect url
      """
  
      _endpoint = None
  
      if isinstance(endpoint, six.string_types):
          _endpoint = endpoint
          # valid for https:// or /path/
          # Endpoint should not have slashes. Use : (colon) to build endpoint
          if "/" in endpoint:
              return f_redirect(endpoint)
          else:
              for r in Mocha._app.url_map.iter_rules():
                  _endpoint = endpoint
                  if 'GET' in r.methods and endpoint in r.endpoint:
                      _endpoint = r.endpoint
                      break
      else:
          # self, will refer the caller method, by getting the method name
          if isinstance(endpoint, Mocha):
              fn = sys._getframe().f_back.f_code.co_name
              endpoint = getattr(endpoint, fn)
  
          if is_method(endpoint):
              _endpoint = _get_action_endpoint(endpoint)
              if not _endpoint:
                  _endpoint = _build_endpoint_route_name(endpoint)
      if _endpoint:
          return f_redirect(url_for(_endpoint, **kw))
      else:
          raise exceptions.MochaError("Invalid endpoint")