From 79ad55e1e0fe746a635e6814fbf048437c2d50ee Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 3 Apr 2023 02:47:11 +0000 Subject: refactor(handler): trait-based response --- src/handler.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/handler.rs') diff --git a/src/handler.rs b/src/handler.rs index f22e3b3..b283cdf 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -30,8 +30,14 @@ pub trait RouteResponse: impl RouteResponse for T where T: FnMut(RouteContext<'_>) -> Response + Send + Sync {} -pub type ErrorResponse = - Box) -> Response + Send + Sync>; +pub trait ErrorResponse: + FnMut(returnable::ErrorContext<'_>) -> Response + Send + Sync +{ +} + +impl ErrorResponse for T where T: FnMut(returnable::ErrorContext<'_>) -> Response + Send + Sync +{} + pub type Callback = Box) + Send + Sync>; pub type CleanupCallback = Box, &mut Response) + Send + Sync>; -- cgit v1.2.3