diff --git a/src/httpcodes.rs b/src/httpcodes.rs index e54876900..87299aaf0 100644 --- a/src/httpcodes.rs +++ b/src/httpcodes.rs @@ -13,7 +13,16 @@ pub const HTTPOk: StaticResponse = StaticResponse(StatusCode::OK); pub const HTTPCreated: StaticResponse = StaticResponse(StatusCode::CREATED); pub const HTTPNoContent: StaticResponse = StaticResponse(StatusCode::NO_CONTENT); +pub const HTTPMultipleChoices: StaticResponse = StaticResponse(StatusCode::MULTIPLE_CHOICES); +pub const HTTPMovedPermanenty: StaticResponse = StaticResponse(StatusCode::MOVED_PERMANENTLY); pub const HTTPFound: StaticResponse = StaticResponse(StatusCode::FOUND); +pub const HTTPSeeOther: StaticResponse = StaticResponse(StatusCode::SEE_OTHER); +pub const HTTPNotModified: StaticResponse = StaticResponse(StatusCode::NOT_MODIFIED); +pub const HTTPUseProxy: StaticResponse = StaticResponse(StatusCode::USE_PROXY); +pub const HTTPTemporaryRedirect: StaticResponse = + StaticResponse(StatusCode::TEMPORARY_REDIRECT); +pub const HTTPPermanentRedirect: StaticResponse = + StaticResponse(StatusCode::PERMANENT_REDIRECT); pub const HTTPBadRequest: StaticResponse = StaticResponse(StatusCode::BAD_REQUEST); pub const HTTPNotFound: StaticResponse = StaticResponse(StatusCode::NOT_FOUND); diff --git a/src/recognizer.rs b/src/recognizer.rs index 2dcb75c38..ff80f624c 100644 --- a/src/recognizer.rs +++ b/src/recognizer.rs @@ -25,7 +25,9 @@ impl Default for RouteRecognizer { impl RouteRecognizer { - pub fn new(prefix: String, routes: Vec<(String, T)>) -> Self { + pub fn new(prefix: P, routes: U) -> Self + where U: IntoIterator + { let mut paths = Vec::new(); let mut handlers = Vec::new(); for item in routes { @@ -36,7 +38,7 @@ impl RouteRecognizer { let regset = RegexSet::new(&paths); RouteRecognizer { - prefix: prefix.len() - 1, + prefix: prefix.to_string().len() - 1, patterns: regset.unwrap(), routes: handlers, }