We need to provide a way for users to create actions that receive values from the Path. Right now, there's only support for the Query, which works for some cases but there are plenty use cases that are not covered. Jupiter uses a path to specify the pair of the swap, i.e. https://jup.ag/swap/SOL-USDC, https://jup.ag/swap/SOL-PYTH. Our current implementation makes it impossible to achieve such behavior.
Axum has the Params extractor as shown below:
// Path segment labels will be matched with struct field names
#[derive(Deserialize)]
struct Params {
user_id: Uuid,
team_id: Uuid,
}
async fn users_teams_show(
Path(Params { user_id, team_id }): Path<Params>,
) {
// ...
}
The implementation details involve changing the way the Context works, and introduces a new variant, we need now 8 (2³) combinations of Context to get it to work in the current way. Which, sure, it's still do-able, but makes it harder to maintain, and if we need a new thing, let's say the "headers" or something, it will add even more combinations.
We need to provide a way for users to create actions that receive values from the Path. Right now, there's only support for the Query, which works for some cases but there are plenty use cases that are not covered. Jupiter uses a path to specify the pair of the swap, i.e. https://jup.ag/swap/SOL-USDC, https://jup.ag/swap/SOL-PYTH. Our current implementation makes it impossible to achieve such behavior.
Axum has the Params extractor as shown below:
The implementation details involve changing the way the Context works, and introduces a new variant, we need now 8 (2³) combinations of Context to get it to work in the current way. Which, sure, it's still do-able, but makes it harder to maintain, and if we need a new thing, let's say the "headers" or something, it will add even more combinations.
An ideal API would be like:
And it would be used like: