-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* axum-macros: use fully qualified Result type (#796) * Easily convert typed paths into URIs (#790) * Easily convert typed paths into URIs `#[derive(TypedPath)]` will now also generate `TryFrom<_> for Uri` for easily converting paths into URIs for use with `Redirect` and friends. Fixes #789 * Use a method on the `TypedPath` trait to convert to `Uri` * fix doc ref * Update changelogs * Remove out of date docs These accidentally weren't removed in #790 Co-authored-by: Matthias Vogelgesang <matthias.vogelgesang@gmail.com>
- Loading branch information
1 parent
558a4d0
commit 84cbb66
Showing
5 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use axum_extra::routing::TypedPath; | ||
use axum::http::Uri; | ||
use serde::Deserialize; | ||
|
||
#[derive(TypedPath, Deserialize)] | ||
#[typed_path("/:id")] | ||
struct Named { | ||
id: u32, | ||
} | ||
|
||
#[derive(TypedPath, Deserialize)] | ||
#[typed_path("/:id")] | ||
struct Unnamed(u32); | ||
|
||
#[derive(TypedPath, Deserialize)] | ||
#[typed_path("/")] | ||
struct Unit; | ||
|
||
fn main() { | ||
let _: Uri = Named { id: 1 }.to_uri(); | ||
let _: Uri = Unnamed(1).to_uri(); | ||
let _: Uri = Unit.to_uri(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters