Skip to content

Commit

Permalink
Rename sync
Browse files Browse the repository at this point in the history
  • Loading branch information
tclem committed Nov 14, 2023
1 parent b4fa115 commit 0dbb7fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions crates/twirp/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ impl Router {
}
}

/// Adds a handler to the router for the given method and path.
pub fn add_handler<F>(&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<F>(&mut self, method: Method, path: &str, f: F)
where
F: Fn(Request<Body>) -> Result<Response<Body>, GenericError>
+ Clone
Expand All @@ -72,7 +72,7 @@ impl Router {
}

/// Adds an async handler to the router for the given method and path.
pub fn add_async_handler<F, Fut>(&mut self, method: Method, path: &str, f: F)
pub fn add_handler<F, Fut>(&mut self, method: Method, path: &str, f: F)
where
F: Fn(Request<Body>) -> Fut + Clone + Sync + Send + 'static,
Fut: Future<Output = Result<Response<Body>, GenericError>> + Send,
Expand Down
2 changes: 1 addition & 1 deletion example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}");
Expand Down

0 comments on commit 0dbb7fe

Please sign in to comment.