YahooArchive / fluxible-router

MOVED TO FLUXIBLE REPO
104 stars 26 forks source link

Dynamic Routes Overlapping Static Routes #46

Closed taylorjames closed 9 years ago

taylorjames commented 9 years ago

is it possible to implement routes that can overlap?

I need to have a dynamic route off of the base route like such

merchant: {
  path: '/:merchantId',
      method: 'get',
      handler: require('../components/merchant'),
      label: 'Home',
      action: (context, payload, done) => {
        var merchantId = payload.get('params').get('merchantId);
        //dispatch something here
    }
}

then I need other routes that overlap the merchant route if is not type of merchantId like such

merchant: {
  path: '/guides',
      method: 'get',
      handler: require('../components/guides'),
      label: 'Home',
      action: (context, payload, done) => {
        //dispatch something here
    }
}

How can I implement this? is there a way I can check the path to see its type and choose what route to use?

redonkulus commented 9 years ago

You should be able to, whatever matches first will be used. So you could have more specific routes first and then have a catch all after that.

lo1tuma commented 9 years ago

@redonkulus I don't think that works, as the routes config is an object you can't control the order of the routes.