Ruxt Macros
This is a collection of macros for the Ruxt web framework.
Installation
Run the following command to add Ruxt to your project:
Add the following to your Cargo.toml:
[]
= "0.1.4"
Usage
async
Basic Routing
The Ruxt main macro will automatically generate routes for files in the routes directory.
The routes are generated based on the file name, so a file named index.rs will be available at the root of the server.
The macro determines which HTTP verb to use based on the function name. For example, a function named get will be a GET route.
So for example:
// routes/index.rs
use ;
pub async
Will be available as a GET request at http://localhost:8080/.
The following verbs are available for routing:
getpostputpatchdelete
Dynamic Paths
Dynamic routes can be created by naming a folder or file with two leading underscores. For example, a folder named __user will create a dynamic route at /user/{id}.
// routes/__user.rs
use ;
pub async
Will be available as a POST request at http://localhost:8080/user/{id}.
Current Limitations
- As of now it is not possible to have a route with the name
modorindexbecause of the way the macro generates routes. I'm looking into a solution for this.
License
This project is licensed under the MIT license.