The demo implemente a simple shortlink services example in rust, using axum.
- Build the devcontainer.
- Run
cargo install cargo-watch systemfdto installCargo Watchandsystmefd. - Run
cargo install diesel_clito installdiesel-clito manage the shipped pg instance. - Run
diesel migration redothendiesel migration runto reset the schema and data in pg.
Choose the pre-create launch config Cargo Launch to debug the app as a normal rust app.
To debug the axum app with auto-reload to free yourself from re-launch the debug, run the Vscode task Cargo Watch first. After the axum app is ready, choose and launch with config Attach to Axum to attach the debugger to the running app.
The task Cargo Watch run this command for you systemfd --no-pid -s http::8080 -- cargo watch --ignore logs -x run.
By default, 8080 for main application and 7878 for management endpoints like metrics and configs.
- Post
localhost:8080/shortlink, takes a url param to return a shortlink. - Get
localhost:8080/{:shorthash}, will redirect you to the url of the shortlink you visit.
- Get
localhost:7878/config, for list all the configs used by the entire application. - Get
localhost:7878/metrics, for prometheus metircs.