Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch all or redirect #335

Open
ghost opened this issue Jun 13, 2016 · 3 comments
Open

catch all or redirect #335

ghost opened this issue Jun 13, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Jun 13, 2016

Maybe I have missed the obvious, but how can I implement a catch all route? I currently have a number of routes, but I want that for any url that does not match one of my routes to be caught and sent to a default page.

@yongnanzhu
Copy link

you can config router with '/:def' tag like {'/:def': defaultPage}

@ghost
Copy link
Author

ghost commented Aug 30, 2016

Currently I am doing:

const router = new director.http.Router({
  '/pws/GetMaterial': {
    get: getMaterial,
  },
  '/pws/AddEvent2': {
    post: genericPost,
  },
});

How would I use '/:def' with this approach, in other words I tried you suggestion and it did not work in the way I am initializing a router.

@mhulse
Copy link

mhulse commented Jan 30, 2017

A catch all that worked for me:

Router(self.routes())
	.configure({
		on: ns.view.table['all routes']
	})
	.init('/');

… and later in my routing table:

'/?((\w|.)*)': ns.view.table['catch all'], // Catches all non-specified routes.
'/': ns.view.table['splash screen']

https://github.com/flatiron/director/blob/b507baed25cfd38307808ea41a0d6305ee6e1ebf/README.md#wildcard-routes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants