From 0dbb7fe08f24a8f17953ad17d9b7621f1215d5bb Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Tue, 14 Nov 2023 07:55:08 -0800 Subject: [PATCH] Rename sync --- crates/twirp/src/server.rs | 6 +++--- example/src/main.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/twirp/src/server.rs b/crates/twirp/src/server.rs index 4938981..674df47 100644 --- a/crates/twirp/src/server.rs +++ b/crates/twirp/src/server.rs @@ -52,8 +52,8 @@ impl Router { } } - /// Adds a handler to the router for the given method and path. - pub fn add_handler(&mut self, method: Method, path: &str, f: F) + /// Adds a sync handler to the router for the given method and path. + pub fn add_sync_handler(&mut self, method: Method, path: &str, f: F) where F: Fn(Request) -> Result, GenericError> + Clone @@ -72,7 +72,7 @@ impl Router { } /// Adds an async handler to the router for the given method and path. - pub fn add_async_handler(&mut self, method: Method, path: &str, f: F) + pub fn add_handler(&mut self, method: Method, path: &str, f: F) where F: Fn(Request) -> Fut + Clone + Sync + Send + 'static, Fut: Future, GenericError>> + Send, diff --git a/example/src/main.rs b/example/src/main.rs index 9b2ae89..2aaf783 100644 --- a/example/src/main.rs +++ b/example/src/main.rs @@ -20,7 +20,7 @@ pub async fn main() { let mut router = Router::default(); let example = Arc::new(HaberdasherAPIServer {}); haberdash::add_service(&mut router, example.clone()); - router.add_handler(Method::GET, "/_ping", |_req| { + router.add_sync_handler(Method::GET, "/_ping", |_req| { Ok(Response::new(Body::from("Pong\n"))) }); println!("{router:?}");