From 59c5e9be6aa6c7af74f03cade6aaf01d90eddc96 Mon Sep 17 00:00:00 2001
From: Nikolay Kim <fafhrd91@gmail.com>
Date: Wed, 25 Dec 2019 21:01:07 +0400
Subject: [PATCH] Use IntoPattern for RouterBuilder::path()

---
 router/CHANGES.txt   | 4 ++++
 router/Cargo.toml    | 2 +-
 router/src/router.rs | 8 ++++++--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/router/CHANGES.txt b/router/CHANGES.txt
index d966586f..9944a14f 100644
--- a/router/CHANGES.txt
+++ b/router/CHANGES.txt
@@ -1,5 +1,9 @@
 # Changes
 
+## [0.2.2] - 2019-12-25
+
+* Use `IntoPattern` for `RouterBuilder::path()`
+
 ## [0.2.1] - 2019-12-25
 
 * Add `IntoPattern` trait
diff --git a/router/Cargo.toml b/router/Cargo.toml
index c93b0ee1..8aba0050 100644
--- a/router/Cargo.toml
+++ b/router/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "actix-router"
-version = "0.2.1"
+version = "0.2.2"
 authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
 description = "Path router"
 keywords = ["actix"]
diff --git a/router/src/router.rs b/router/src/router.rs
index bffc208f..c65ac2db 100644
--- a/router/src/router.rs
+++ b/router/src/router.rs
@@ -1,4 +1,4 @@
-use crate::{Resource, ResourceDef, ResourcePath};
+use crate::{IntoPattern, Resource, ResourceDef, ResourcePath};
 
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct ResourceId(pub u16);
@@ -70,7 +70,11 @@ pub struct RouterBuilder<T, U = ()> {
 
 impl<T, U> RouterBuilder<T, U> {
     /// Register resource for specified path.
-    pub fn path(&mut self, path: &str, resource: T) -> &mut (ResourceDef, T, Option<U>) {
+    pub fn path<P: IntoPattern>(
+        &mut self,
+        path: P,
+        resource: T,
+    ) -> &mut (ResourceDef, T, Option<U>) {
         self.resources
             .push((ResourceDef::new(path), resource, None));
         self.resources.last_mut().unwrap()