Skip to main content

normalize_to_axum_path

Function normalize_to_axum_path 

Source
pub fn normalize_to_axum_path(path: &str) -> String
Expand description

Convert OpenAPI-style path placeholders to Axum 0.8+ style path parameters.

Axum 0.8+ uses {id} for path parameters and {*path} for wildcards, which is the same as OpenAPI. However, OpenAPI wildcards are just {path} without the asterisk. This function converts OpenAPI wildcards to Axum wildcards by detecting common wildcard names.

ยงExamples

assert_eq!(normalize_to_axum_path("/users/{id}"), "/users/{id}");
assert_eq!(normalize_to_axum_path("/projects/{project_id}/items/{item_id}"), "/projects/{project_id}/items/{item_id}");
// Note: Most paths don't need normalization in Axum 0.8+