From cbc378b67ff3c770f3b9d0b98ccb551974bbe031 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 15 Jan 2019 19:25:49 -0800 Subject: [PATCH] allow deserialize from the path --- actix-service/CHANGES.md | 3 +++ actix-service/Cargo.toml | 2 +- router/src/path.rs | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/actix-service/CHANGES.md b/actix-service/CHANGES.md index 9b83cad4..cc9dd9ef 100644 --- a/actix-service/CHANGES.md +++ b/actix-service/CHANGES.md @@ -1,5 +1,8 @@ # Changes +## [0.1.6] - 2019-01-xx + + ## [0.1.5] - 2019-01-13 ### Changed diff --git a/actix-service/Cargo.toml b/actix-service/Cargo.toml index 5dd02754..9579e2b5 100644 --- a/actix-service/Cargo.toml +++ b/actix-service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-service" -version = "0.1.5" +version = "0.1.6" authors = ["Nikolay Kim "] description = "Actix Service" keywords = ["network", "framework", "async", "futures"] diff --git a/router/src/path.rs b/router/src/path.rs index bcd4439f..9fe94f25 100644 --- a/router/src/path.rs +++ b/router/src/path.rs @@ -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 Path { params: self, } } + + /// Try to deserialize matching parameters to a specified type `U` + pub fn load<'de, U: serde::Deserialize<'de>>(&'de self) -> Result { + de::Deserialize::deserialize(PathDeserializer::new(self)) + } } #[derive(Debug)]