Vvinhnx

axum-0-7-to-0-8

Migrate Rust axum routing path syntax from 0.7 to 0.8 for route, route_service, nest, and nest_service definitions

rustaxumroutingwebmigration0.7-to-0.8path-parameters
Public
2 executions
2 stars
How to Use
Run this codemod on your codebase using the following command

The easiest way to run this codemod without installing anything globally:

Documentation

axum-0-7-to-0-8

Automate the highest-value deterministic part of the Rust axum migration from v0.7 to v0.8.

What it does

Route path syntax updates

  • /:id -> /{id}
  • /*rest -> /{*rest}
  • Rewrites path strings passed to:
    • .route(...)
    • .route_service(...)
    • .nest(...)
    • .nest_service(...)
  • Supports normal Rust string literals and raw string literals used in those route definitions

Cargo.toml follow-up

  • Update axum = "0.7.x" -> axum = "0.8"
  • Update axum = { version = "0.7.x", ... } -> axum = { version = "0.8", ... }

Usage

bash

Manual follow-up

After running, you should:

  1. Review Cargo.toml updates for uncommon axum dependency formatting not covered by deterministic rewrites
  2. Review custom route strings outside .route, .route_service, .nest, and .nest_service
  3. Check code using Option<Path<T>> or other optional extractors for behavior changes in axum 0.8
  4. Review custom FromRequest and FromRequestParts implementations if they rely on #[async_trait]
  5. Run cargo check and cargo test

Development

bash

References

License

MIT

Before

This is one example from the codemod's test cases. The codemod may handle many more cases.

Ready to contribute?

Build your own codemod and share it with the community.