I like what’s in the post and think waiting for some improvements to Rust for a better UX is totally worth it.
Something that seems missing (or that I didn’t see) is a way to resolve (called reverse in Django) a URL in the views.
Let’s say you have the following routes:
order-details: /orders/{id}
checkout: /checkout
and imagine you want to redirect the user after a POST on the checkout route to its order page with the newly created order ID.
In Django you would redirect to the URL given by reverse("order-details", kwargs={'id': order.id}).
This requires 2 things (well 3, I’ll expand on the last one a bit later):
- named routes: if I change a URL, I only want to change it at one place, not everywhere
- named parameters: we could potentially skip that but it avoids tons of bugs and improve readability so that would be sad to not have them
The last point that would be nice, providing we have named routes is namespaces. It has been mentioned before as subrouters providing some routes.
If I do router.mount("/auth", "auth", &auth_urls) with the parameters being (prefix, namespace, router), I should be able to redirect to /auth/login by doing reverse("auth:login") for example if we follow the Django example and there is a view named login in the auth subrouter.