mirror of https://github.com/fafhrd91/actix-net
				
				
				
			Merge branch 'master' into tokio-compat-support
This commit is contained in:
		
						commit
						35df35cf97
					
				| 
						 | 
					@ -1,3 +0,0 @@
 | 
				
			||||||
# actix-ioframe
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
**This crate has been deprecated and removed.**
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,53 +1,55 @@
 | 
				
			||||||
# Changes
 | 
					# Changes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.2.4] - 2019-12-31
 | 
					## Unreleased - 2020-xx-xx
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.2.5 - 2020-09-20
 | 
				
			||||||
 | 
					* Fix `from_hex()` method
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.2.4 - 2019-12-31
 | 
				
			||||||
* Add `ResourceDef::resource_path_named()` path generation method
 | 
					* Add `ResourceDef::resource_path_named()` path generation method
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.2.3] - 2019-12-25
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.2.3 - 2019-12-25
 | 
				
			||||||
* Add impl `IntoPattern` for `&String`
 | 
					* Add impl `IntoPattern` for `&String`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.2.2] - 2019-12-25
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.2.2 - 2019-12-25
 | 
				
			||||||
* Use `IntoPattern` for `RouterBuilder::path()`
 | 
					* Use `IntoPattern` for `RouterBuilder::path()`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.2.1] - 2019-12-25
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.2.1 - 2019-12-25
 | 
				
			||||||
* Add `IntoPattern` trait
 | 
					* Add `IntoPattern` trait
 | 
				
			||||||
 | 
					 | 
				
			||||||
* Add multi-pattern resources
 | 
					* Add multi-pattern resources
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.2.0] - 2019-12-07
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.2.0 - 2019-12-07
 | 
				
			||||||
* Update http to 0.2
 | 
					* Update http to 0.2
 | 
				
			||||||
 | 
					 | 
				
			||||||
* Update regex to 1.3
 | 
					* Update regex to 1.3
 | 
				
			||||||
 | 
					 | 
				
			||||||
* Use bytestring instead of string
 | 
					* Use bytestring instead of string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.1.5] - 2019-05-15
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.1.5 - 2019-05-15
 | 
				
			||||||
* Remove debug prints
 | 
					* Remove debug prints
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.1.4] - 2019-05-15
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.1.4 - 2019-05-15
 | 
				
			||||||
* Fix checked resource match
 | 
					* Fix checked resource match
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.1.3] - 2019-04-22
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.1.3 - 2019-04-22
 | 
				
			||||||
* Added support for `remainder match` (i.e "/path/{tail}*")
 | 
					* Added support for `remainder match` (i.e "/path/{tail}*")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.1.2] - 2019-04-07
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.1.2 - 2019-04-07
 | 
				
			||||||
* Export `Quoter` type
 | 
					* Export `Quoter` type
 | 
				
			||||||
 | 
					 | 
				
			||||||
* Allow to reset `Path` instance
 | 
					* Allow to reset `Path` instance
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.1.1] - 2019-04-03
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.1.1 - 2019-04-03
 | 
				
			||||||
* Get dynamic segment by name instead of iterator.
 | 
					* Get dynamic segment by name instead of iterator.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [0.1.0] - 2019-03-09
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## 0.1.0 - 2019-03-09
 | 
				
			||||||
* Initial release
 | 
					* Initial release
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,8 @@
 | 
				
			||||||
[package]
 | 
					[package]
 | 
				
			||||||
name = "actix-router"
 | 
					name = "actix-router"
 | 
				
			||||||
version = "0.2.4"
 | 
					version = "0.2.5"
 | 
				
			||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
 | 
					authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
 | 
				
			||||||
description = "Path router"
 | 
					description = "Resource path matching library"
 | 
				
			||||||
keywords = ["actix"]
 | 
					keywords = ["actix"]
 | 
				
			||||||
homepage = "https://actix.rs"
 | 
					homepage = "https://actix.rs"
 | 
				
			||||||
repository = "https://github.com/actix/actix-net.git"
 | 
					repository = "https://github.com/actix/actix-net.git"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -161,9 +161,7 @@ impl<'de, T: ResourcePath + 'de> Deserializer<'de> for PathDeserializer<'de, T>
 | 
				
			||||||
        V: Visitor<'de>,
 | 
					        V: Visitor<'de>,
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if self.path.is_empty() {
 | 
					        if self.path.is_empty() {
 | 
				
			||||||
            Err(de::value::Error::custom(
 | 
					            Err(de::value::Error::custom("expected at least one parameters"))
 | 
				
			||||||
                "expeceted at least one parameters",
 | 
					 | 
				
			||||||
            ))
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            visitor.visit_enum(ValueEnum {
 | 
					            visitor.visit_enum(ValueEnum {
 | 
				
			||||||
                value: &self.path[0],
 | 
					                value: &self.path[0],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
//! Resource path matching library.
 | 
					//! Resource path matching library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mod de;
 | 
					mod de;
 | 
				
			||||||
mod path;
 | 
					mod path;
 | 
				
			||||||
mod resource;
 | 
					mod resource;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -155,7 +155,7 @@ impl ResourceDef {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[inline]
 | 
					    #[inline]
 | 
				
			||||||
    /// Check if path matchs this pattern?
 | 
					    /// Check if path matches this pattern.
 | 
				
			||||||
    pub fn is_match(&self, path: &str) -> bool {
 | 
					    pub fn is_match(&self, path: &str) -> bool {
 | 
				
			||||||
        match self.tp {
 | 
					        match self.tp {
 | 
				
			||||||
            PatternType::Static(ref s) => s == path,
 | 
					            PatternType::Static(ref s) => s == path,
 | 
				
			||||||
| 
						 | 
					@ -165,7 +165,7 @@ impl ResourceDef {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Is prefix path a match against this resource?
 | 
					    /// Is prefix path a match against this resource.
 | 
				
			||||||
    pub fn is_prefix_match(&self, path: &str) -> Option<usize> {
 | 
					    pub fn is_prefix_match(&self, path: &str) -> Option<usize> {
 | 
				
			||||||
        let plen = path.len();
 | 
					        let plen = path.len();
 | 
				
			||||||
        let path = if path.is_empty() { "/" } else { path };
 | 
					        let path = if path.is_empty() { "/" } else { path };
 | 
				
			||||||
| 
						 | 
					@ -240,7 +240,7 @@ impl ResourceDef {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Is the given path and parameters a match against this pattern?
 | 
					    /// Is the given path and parameters a match against this pattern.
 | 
				
			||||||
    pub fn match_path<T: ResourcePath>(&self, path: &mut Path<T>) -> bool {
 | 
					    pub fn match_path<T: ResourcePath>(&self, path: &mut Path<T>) -> bool {
 | 
				
			||||||
        match self.tp {
 | 
					        match self.tp {
 | 
				
			||||||
            PatternType::Static(ref s) => {
 | 
					            PatternType::Static(ref s) => {
 | 
				
			||||||
| 
						 | 
					@ -875,7 +875,7 @@ mod tests {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[test]
 | 
					    #[test]
 | 
				
			||||||
    fn test_reousrce_prefix_dynamic() {
 | 
					    fn test_resource_prefix_dynamic() {
 | 
				
			||||||
        let re = ResourceDef::prefix("/{name}/");
 | 
					        let re = ResourceDef::prefix("/{name}/");
 | 
				
			||||||
        assert!(re.is_match("/name/"));
 | 
					        assert!(re.is_match("/name/"));
 | 
				
			||||||
        assert!(re.is_match("/name/gs"));
 | 
					        assert!(re.is_match("/name/gs"));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -186,7 +186,7 @@ fn from_hex(v: u8) -> Option<u8> {
 | 
				
			||||||
        Some(v - 0x30) // ord('0') == 0x30
 | 
					        Some(v - 0x30) // ord('0') == 0x30
 | 
				
			||||||
    } else if v >= b'A' && v <= b'F' {
 | 
					    } else if v >= b'A' && v <= b'F' {
 | 
				
			||||||
        Some(v - 0x41 + 10) // ord('A') == 0x41
 | 
					        Some(v - 0x41 + 10) // ord('A') == 0x41
 | 
				
			||||||
    } else if v > b'a' && v <= b'f' {
 | 
					    } else if v >= b'a' && v <= b'f' {
 | 
				
			||||||
        Some(v - 0x61 + 10) // ord('a') == 0x61
 | 
					        Some(v - 0x61 + 10) // ord('a') == 0x61
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        None
 | 
					        None
 | 
				
			||||||
| 
						 | 
					@ -225,4 +225,25 @@ mod tests {
 | 
				
			||||||
        assert!(re.match_path(&mut path));
 | 
					        assert!(re.match_path(&mut path));
 | 
				
			||||||
        assert_eq!(path.get("id").unwrap(), "qwe%rty");
 | 
					        assert_eq!(path.get("id").unwrap(), "qwe%rty");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #[test]
 | 
				
			||||||
 | 
					    fn test_from_hex() {
 | 
				
			||||||
 | 
					        let hex = b"0123456789abcdefABCDEF";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for i in 0..256 {
 | 
				
			||||||
 | 
					            let c = i as u8;
 | 
				
			||||||
 | 
					            if hex.contains(&c) {
 | 
				
			||||||
 | 
					                assert!(from_hex(c).is_some())
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                assert!(from_hex(c).is_none())
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let expected = [
 | 
				
			||||||
 | 
					            0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10, 11, 12, 13, 14, 15,
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					        for i in 0..hex.len() {
 | 
				
			||||||
 | 
					            assert_eq!(from_hex(hex[i]).unwrap(), expected[i]);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue