Programmable router

So we are about to go into production with our new site in xp which previously resided under cms.

Since we have a bunch of services which depend upon content in the old cms site, which does not exist, and probably never will, in the new xp site, we cannot simply take the old cms site offline.

So we have made another dns entry for the old site prefixed “retro”.

And when we go live, we will simply update the dns so the xp site lives on the same url the cms site did.

Since we do not know everywhere the old urls are used, we need to have redirects for a while.

We could invent a redirect content type, and make “endpoints” in Content Studio with it, but that would clutter up content studio, and also not catch unknown endpoints.

So we need to be able to use regexes.

I can do this in the error handler, but I’d rather do it in a programmable router.

How about using the error handler?
Then if you get a 404:

  • Log the URL/register it somewhere so you can move it.
  • Check if the old cms has that resource and redirect if so
  • Return 404-page if neither system has it

Haven’t tried this yet, but this is how I have thought about doing this when it comes up.

1 Like

Not really sure what you want to do?
Do you want to route some specific traffic hitting the xp installation to the retro site? If so, i propose one of the following (in preferred order):

  • Use rewrites in apache
  • Add handle404 error.js with a list of regex to redirect
  • Add separate app with explicit mappings, and add it to the site - so you can release it frequently, and avoid cluttering your main app (available in 6.7)

Yes.

I already suggested using the error handler in my first post.

I would actually put the regexps somewhere in content studio so editors could update the list.

When we switched out an old cms site, with a new cms site last year, we did all the redirection in cms.

And the reason I’m suggesting making the router available for programming is that’s what I could easily do in Ruby on rail.

Using apache for redirects sounds good in theory, but requires involving external OPS people, and possibly ITIL regime, which does not handle rapid changes… Also maintaining apache redirect on multiple cluster nodes sound like pain.

I’m gonna implement it in content studio and error handler for now.

Keeping my fond wishes for a programmable router for later :slight_smile:

A router will come, but no eariler than 7.0 - check out purpleJS to get an idea of what we’re talking about :slight_smile:

There is sorta a programmable router already:
http://xp.readthedocs.io/en/stable/developer/site/mappings/index.html#controller-mappings