-
Notifications
You must be signed in to change notification settings - Fork 17
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
Ability to exclude certain routes #20
Comments
I came up with a simple solution to allow this functionality. @danielb2 please let me know if you like it and if you are going to implement it as I need it on my project. I'll paste here the modified code. Thanks internals.connectionInfo = function (routes, options, connectionInfo) {
for (var i = 0, il = routes.length; i < il; ++i) {
var route = routes[i];
if (!route.settings.plugins.blipp || !route.settings.plugins.blipp.excluded) {
var defaultStrategy = Hoek.reach(route, 'connection.auth.settings.default.strategies');
var authStrategy = route.settings.auth ? route.settings.auth.strategies.toString() : false;
if (route.settings.auth === undefined) {
authStrategy = defaultStrategy ? String(defaultStrategy) : false;
}
var show = {
method: route.method.toUpperCase(),
path: route.path,
description: route.settings.description || ''
};
if (options.showAuth) {
show.auth = authStrategy;
};
connectionInfo.routes.push(show);
}
}
connectionInfo.routes.sort(function (a, b) {
return a.path.localeCompare(b.path);
});
}; Now, you can simply add in the config object of your route the option to exclude that route. i.e {
path: '/doc/category',
method: 'POST',
handler: (req, reply) => {
reply('OK');
},
config: {
description: 'Add new category',
tags: ['api'],
plugins: {
blipp: {
excluded: true
}
}
}
} |
would it be easier to just have a list of paths in the plugin registration of what to exclude? Or is on a per-route basis better? Seems like more work to do it per route:
|
Well, actually both implementations are very useful. And at plugin level it would be good if we can use regex to express the routes. |
What's the problem with having IOW, what's the use-case for hiding routes that do exist? |
Sometimes you may have some routes for testing purpose or, in the case of hapi-swagger, a lot of routes for documentation. If your API has a lot of endpoints and each endpoint has its documentation route, then you end up with lot of endpoints your API doesn't export (as I said, they are just for internal use only). |
How are you blocking off the endpoints which are for internal use only then? If they're on a different connection, blipp will show it as being on the other connection. btw, I've already implemented the code in the |
Could you perhaps add an option to the option to exclude certain routes? I'm using the hapi-swagger plugin, and now blipp shows the /docs and /documentation routes in the route table.
The text was updated successfully, but these errors were encountered: