Managing views using the Actix Web framework
In the Launching a basic Actix Web server section, we defined our views in the main.rs file. However, this is not scalable. If we continue to define all our routes in main, we will end up with a lot of imports and route definitions in one file. This makes it hard to navigate and manage. If we want to change a URL prefix for a block of views, the editing in this context is error-prone. The same goes for disabling a block of views.
In order to manage our views, we need to create our own modules for each set of views. To manage our views, we create a new Cargo project called managing_views. We then define the following project structure:
├── main.rs └── views     ├── auth     │   ├── login.rs     │   ├── logout.rs    ...