title: How to redirect some URL conditionally in the koa 2
body: <p>This is what i'm thinking, pseudo code. </p>
  
  <pre><code>const myRedirect = (routePath) =&gt; {
      newUrl = routePath;
      if (matches condition)
          newUrl = do_some_modification(routePath);       
      return next(newUrl); 
  }
  
  const myFunc = (routePath, myRedirect) =&gt; (newUrl, middleware) =&gt; {
      return (ctx, newUrl, next) =&gt; {
          return middleware(ctx, newUrl, next);
      }
  };
  </code></pre>
  
  <p>How to modify it to make it work please ?</p>