1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-28 20:10:35 +02:00

Use IntoPattern for RouterBuilder::path()

This commit is contained in:
Nikolay Kim
2019-12-25 21:01:07 +04:00
parent a2a9d9764d
commit 59c5e9be6a
3 changed files with 11 additions and 3 deletions

View File

@ -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()