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

Add root configuration option for relative routing #215

Open
svicalifornia opened this issue Sep 21, 2017 · 1 comment
Open

Add root configuration option for relative routing #215

svicalifornia opened this issue Sep 21, 2017 · 1 comment

Comments

@svicalifornia
Copy link
Contributor

Most APIs have a common prefix in all of their routes, e.g. /api/v1/

Repeating this prefix in all Pretender routes is less than ideal. It's not DRY, and an API prefix can sometimes change, requiring redundant edits across all routes.

It would be great if we could configure a shared root and specify the routes relative to this root, as shown below:

const server = new Pretender();
server.root = '/api/v1/';
server.get('users', ... );
server.get('users/:id', ... );
server.get('products', ... );
server.get('products/:id', ... );
@svicalifornia
Copy link
Contributor Author

Even better, this root property could be used to limit which requests will be handled by Pretender, so that requests to other URLs that don't match would automatically pass through.

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

1 participant