mirror of
https://github.com/fafhrd91/actix-net
synced 2025-01-18 20:01:48 +01:00
Use IntoPattern for RouterBuilder::path()
This commit is contained in:
parent
a2a9d9764d
commit
59c5e9be6a
@ -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
|
||||
|
@ -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"]
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user