mirror of
https://github.com/fafhrd91/actix-web
synced 2025-05-19 23:43:17 +02:00
allow deserialize from the path
This commit is contained in:
parent
323b9a834f
commit
fc5a0e8821
@ -1,6 +1,9 @@
|
||||
use std::ops::Index;
|
||||
use std::rc::Rc;
|
||||
|
||||
use serde::de;
|
||||
|
||||
use crate::de::PathDeserializer;
|
||||
use crate::RequestPath;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
@ -149,6 +152,11 @@ impl<T: RequestPath> Path<T> {
|
||||
params: self,
|
||||
}
|
||||
}
|
||||
|
||||
/// Try to deserialize matching parameters to a specified type `U`
|
||||
pub fn load<'de, U: serde::Deserialize<'de>>(&'de self) -> Result<U, de::value::Error> {
|
||||
de::Deserialize::deserialize(PathDeserializer::new(self))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user