diff --git a/example/src/main.rs b/example/src/main.rs index 8dfc0b4..3d9a249 100644 --- a/example/src/main.rs +++ b/example/src/main.rs @@ -136,8 +136,8 @@ fn main() gotham::start(ADDR, build_router(chain, pipelines, |route| { route.with_openapi("Users Example".to_owned(), "0.0.1".to_owned(), format!("http://{}", ADDR), |mut route| { - route.resource::("users"); - route.resource::("auth"); + route.resource::("users"); + route.resource::("auth"); route.get_openapi("openapi"); }); })); diff --git a/gotham_restful/src/openapi/router.rs b/gotham_restful/src/openapi/router.rs index 6e52db1..a4aad3e 100644 --- a/gotham_restful/src/openapi/router.rs +++ b/gotham_restful/src/openapi/router.rs @@ -370,13 +370,13 @@ macro_rules! implOpenapiRouter { C : PipelineHandleChain

+ Copy + Send + Sync + 'static, P : RefUnwindSafe + Send + Sync + 'static { - fn resource(&mut self, path : T) + fn resource(&mut self, path : &str) { - R::setup((self, path.to_string())); + R::setup((self, path)); } } - impl<'a, C, P> DrawResourceRoutes for (&mut (&mut $implType<'a, C, P>, &mut OpenapiRouter), String) + impl<'a, C, P> DrawResourceRoutes for (&mut (&mut $implType<'a, C, P>, &mut OpenapiRouter), &str) where C : PipelineHandleChain

+ Copy + Send + Sync + 'static, P : RefUnwindSafe + Send + Sync + 'static @@ -393,7 +393,7 @@ macro_rules! implOpenapiRouter { item.get = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::default(), None, None, Res::requires_auth())); (self.0).1.add_path(path, item); - (&mut *(self.0).0, self.1.to_string()).read_all::() + (&mut *(self.0).0, self.1).read_all::() } fn read(&mut self) @@ -409,7 +409,7 @@ macro_rules! implOpenapiRouter { item.get = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::from_path_params(vec!["id"]), None, None, Res::requires_auth())); (self.0).1.add_path(path, item); - (&mut *(self.0).0, self.1.to_string()).read::() + (&mut *(self.0).0, self.1).read::() } fn search(&mut self) @@ -425,7 +425,7 @@ macro_rules! implOpenapiRouter { item.get = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::from_query_params(Query::schema()), None, None, Res::requires_auth())); (self.0).1.add_path(path, item); - (&mut *(self.0).0, self.1.to_string()).search::() + (&mut *(self.0).0, self.1).search::() } fn create(&mut self) @@ -442,7 +442,7 @@ macro_rules! implOpenapiRouter { item.post = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::default(), Some(body_schema), Body::supported_types(), Res::requires_auth())); (self.0).1.add_path(path, item); - (&mut *(self.0).0, self.1.to_string()).create::() + (&mut *(self.0).0, self.1).create::() } fn update_all(&mut self) @@ -459,7 +459,7 @@ macro_rules! implOpenapiRouter { item.put = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::default(), Some(body_schema), Body::supported_types(), Res::requires_auth())); (self.0).1.add_path(path, item); - (&mut *(self.0).0, self.1.to_string()).update_all::() + (&mut *(self.0).0, self.1).update_all::() } fn update(&mut self) @@ -477,7 +477,7 @@ macro_rules! implOpenapiRouter { item.put = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::from_path_params(vec!["id"]), Some(body_schema), Body::supported_types(), Res::requires_auth())); (self.0).1.add_path(path, item); - (&mut *(self.0).0, self.1.to_string()).update::() + (&mut *(self.0).0, self.1).update::() } fn delete_all(&mut self) @@ -492,7 +492,7 @@ macro_rules! implOpenapiRouter { item.delete = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::default(), None, None, Res::requires_auth())); (self.0).1.add_path(path, item); - (&mut *(self.0).0, self.1.to_string()).delete_all::() + (&mut *(self.0).0, self.1).delete_all::() } fn delete(&mut self) @@ -508,7 +508,7 @@ macro_rules! implOpenapiRouter { item.delete = Some(new_operation(Res::default_status(), Res::accepted_types(), schema, OperationParams::from_path_params(vec!["id"]), None, None, Res::requires_auth())); (self.0).1.add_path(path, item); - (&mut *(self.0).0, self.1.to_string()).delete::() + (&mut *(self.0).0, self.1).delete::() } } diff --git a/gotham_restful/src/routing.rs b/gotham_restful/src/routing.rs index 2b0181f..ac1628d 100644 --- a/gotham_restful/src/routing.rs +++ b/gotham_restful/src/routing.rs @@ -60,7 +60,7 @@ pub trait WithOpenapi /// any RESTful `Resource` with a path. pub trait DrawResources { - fn resource(&mut self, path : T); + fn resource(&mut self, path : &str); } /// This trait allows to draw routes within an resource. Use this only inside the @@ -356,14 +356,14 @@ macro_rules! implDrawResourceRoutes { C : PipelineHandleChain

+ Copy + Send + Sync + 'static, P : RefUnwindSafe + Send + Sync + 'static { - fn resource(&mut self, path : T) + fn resource(&mut self, path : &str) { - R::setup((self, path.to_string())); + R::setup((self, path)); } } #[allow(clippy::redundant_closure)] // doesn't work because of type parameters - impl<'a, C, P> DrawResourceRoutes for (&mut $implType<'a, C, P>, String) + impl<'a, C, P> DrawResourceRoutes for (&mut $implType<'a, C, P>, &str) where C : PipelineHandleChain

+ Copy + Send + Sync + 'static, P : RefUnwindSafe + Send + Sync + 'static