Adds ability to list routes for lucky routes command #64
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.
Fixes #57
Lucky stores its own routes array and it is only for the
lucky routes
CLI command. By adding this functionality here, we remove the need for that. The basic logic of this code is that a fragment returns a list of any methods to payload that it has along with its path. Beyond that, it cycles through any sub-fragments it might have and does the same for those and prepends its own path to any results received from it. That ultimately bubbles up to a single list of routes. Only thing we do beyond that is to convert the list of PathPart's into a string. We filter out any of the blank path parts that are at the start and join with "/" and make sure to prepend one as well. It gets a little funky when query params are passed in, but Lucky doesn't do that at all so it shouldn't be a problem. The problem there is that it makes a ton of routes. With query param, without, not including if there's more than one.Lucky router with duplicate routes array: https://github.com/luckyframework/lucky/blob/main/src/lucky/router.cr
CLI command: https://github.com/luckyframework/lucky/blob/main/tasks/routes.cr