aboutsummaryrefslogtreecommitdiff
path: root/src/handler.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-04-03 02:47:11 +0000
committerFuwn <[email protected]>2023-04-03 02:47:11 +0000
commit79ad55e1e0fe746a635e6814fbf048437c2d50ee (patch)
tree12c395e03accf4a4a115b24946760bcae5d0d148 /src/handler.rs
parentfeat(router): GET RID OF DIRTY BOXES (diff)
downloadwindmark-79ad55e1e0fe746a635e6814fbf048437c2d50ee.tar.xz
windmark-79ad55e1e0fe746a635e6814fbf048437c2d50ee.zip
refactor(handler): trait-based response
Diffstat (limited to 'src/handler.rs')
-rw-r--r--src/handler.rs10
1 files changed, 8 insertions, 2 deletions
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<T> RouteResponse for T where T: FnMut(RouteContext<'_>) -> Response + Send + Sync
{}
-pub type ErrorResponse =
- Box<dyn FnMut(returnable::ErrorContext<'_>) -> Response + Send + Sync>;
+pub trait ErrorResponse:
+ FnMut(returnable::ErrorContext<'_>) -> Response + Send + Sync
+{
+}
+
+impl<T> ErrorResponse for T where T: FnMut(returnable::ErrorContext<'_>) -> Response + Send + Sync
+{}
+
pub type Callback = Box<dyn FnMut(CallbackContext<'_>) + Send + Sync>;
pub type CleanupCallback =
Box<dyn FnMut(CallbackContext<'_>, &mut Response) + Send + Sync>;