gotham icon indicating copy to clipboard operation
gotham copied to clipboard

Automatic Route Building

Open Nokel81 opened this issue 6 years ago • 9 comments

I don't know how feasible this is but something I really liked about NodeJS/express which I don't think can currently be done in Rust/Gotham is generating routes based on the file system tree structure.

What I am thinking is having a AutoTreeBuilder that you point to a folder and then it goes through its children and child folders looking for pub Nodes. These nodes' routes would be overwritten with the tree path.

Middlewear would be able to be available by name for the node to add for specific routes.

Nokel81 avatar Aug 11 '17 22:08 Nokel81

I would be willing to help with the implementation

Nokel81 avatar Aug 11 '17 22:08 Nokel81

@Nokel81 I've not actually played with express that much, could you provide a link to their documentation on this so I can have a look?

If you'd like to have a poke around and experiment with some code I'd be interested to see what you come up with.

The stability goal we have for Gotham will probably see us be a little cautious in taking too much into the core to quickly, once something is in we want to support it for a long time. A set of third party crates that provide specific functionality in extension to Gotham core is certainly something we'd like to encourage, perhaps this would end up fitting there?.

bradleybeddoes avatar Aug 13 '17 09:08 bradleybeddoes

It may be better as TP crate but I will do some playing around. Also the way that express allows this to happen is through the export of functions from files and the fact that in express a endpoint is just a function that takes some parameters

Nokel81 avatar Aug 13 '17 11:08 Nokel81

What does spike mean?

Nokel81 avatar Aug 19 '17 10:08 Nokel81

@Nokel81 spike is an agile-ish term, that indicates some sort of work is going on, research, prototype creation, mock-ups etc to try and figure out if a concept is achievable, how it might look etc. Essentially any work that may help us decide to move something into development work for a specific feature (at which point we'd remove spike and apply feature whilst "proper" implementation was undertaken).

Mostly it is a method to visualise where all our tickets are up to.

Does that help?

bradleybeddoes avatar Aug 20 '17 23:08 bradleybeddoes

Yes, thank you

Nokel81 avatar Aug 20 '17 23:08 Nokel81

The way I plan to do this would be with the file! macro and this would be for paths that don't use dynamic path values

Nokel81 avatar Sep 19 '17 20:09 Nokel81

@Nokel81 hi! Sorry that this has been left so long. I'm interested in this issue as I also used to wire my Node apps in the same way.

Do you have any ideas on what you might imagine an interface to look like for this? If you have any thoughts on what the filesystem structure should be, and how we would go about implementing it? It seems like it could be quite difficult due to the nature of Rust.

whitfin avatar Oct 02 '18 00:10 whitfin

It does seem that it would be quite difficult to don't in rust. What I think would have to be done is to use the rust build script systems.

In the cargo.toml the root of the path would have to be passed in. Then the build script finds all the routes and outputs the correct path commands to a function (or something)

Nokel81 avatar Oct 02 '18 14:10 Nokel81