Re:Pencil: A Microframework Inspired by Flask for Rust
by fredsir on Wednesday March 09, 2016 @03:26AM
(#11251668)
That seems like a good approach, although one thing is missing: when you use the route-decorator in Flask, the route is registered to the app object "via magic", whereas in your example, you still have to register it manually (`app.route(user())`). Now, I am partial to liking registering manually, like in your example and in Pencil itself, since that's clearer than having a lot of routes spread around in a whole lot of files that are magically registered, but just for the kicks, would it be possible to not having to manually register the route to the app object?
To use the above route, you would simply have a `Route` trait perhaps.
And implement it for each generated struct: Then you could use the route as Which could be defined as