Add the route options to the "routeObj" emited by the "router:bind" sails event #3326
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A small modification to include the route options in the object emitted by the
router:bind
event.That would be very useful for hooks. It could replace (or maybe be used to implement?) the
sails.getRoutes()
method proposed in the comments of PR-2659.Besides being useful for routing and debugging hooks, it could be used to generate api documentations like Swagger, Raml or API Blueprint. For example, the sails-swagger hook is kind of reverse engineering the content of
sails.router._privateRouter.routes
to find models associated to routes. The task is even more awkward if you have to retrieve blueprint prefixes or manage theblueprints.pluralize
configuration.Having the possibility to read the route's options when listening at the
router:bind
event would make this task trivial. Example of value retrieved for a rest blueprint route:Finally,
options
is already available in the object emitted by therouter:route
event. I think it would make sense to make it available whenrouter:bind
is fired too.