checkpoint

This commit is contained in:
David Pedersen
2022-02-13 13:29:01 +01:00
parent c84d6d66d4
commit 47f5954903
5 changed files with 80 additions and 52 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
use axum::{body::Body, Router};
mod resource;
mod typed_path;
pub mod typed_path;
pub use self::{resource::Resource, typed_path::TypedPath};
+19 -4
View File
@@ -1,10 +1,25 @@
#![allow(missing_docs)]
use axum::extract::{FromRequest, Path};
use serde::de::DeserializeOwned;
use std::borrow::Cow;
/// TODO
pub trait TypedPath {
/// TODO
/// ```rust
/// use axum_macros::TypedPath;
///
/// #[derive(TypedPath)]
/// #[typed_path("/users/:id")]
/// struct UsersShow {
/// id: u32,
/// }
/// ```
pub trait TypedPath<B>: FromRequest<B> + DeserializeOwned {
const PATH: &'static str;
/// TODO
fn path(&self) -> Cow<'static, str>;
}
// pub trait FirstElementIsPath {}
// impl<P> FirstElementIsPath for (Path<P>,) {}
// impl<P, T1> FirstElementIsPath for (Path<P>, T1) {}
// impl<P, T1, T2> FirstElementIsPath for (Path<P>, T1, T2) {}