aboutsummaryrefslogtreecommitdiff
path: root/src/handler.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-04-03 03:01:20 +0000
committerFuwn <[email protected]>2023-04-03 03:01:20 +0000
commit9dcb9e8651c2d2cde8854277c9dcb96a4f1af7b9 (patch)
treee5c41a2b7e4258d3a9b24c800d9b87649f38581d /src/handler.rs
parentrefactor(handler): move all responses to traits (diff)
downloadwindmark-9dcb9e8651c2d2cde8854277c9dcb96a4f1af7b9.tar.xz
windmark-9dcb9e8651c2d2cde8854277c9dcb96a4f1af7b9.zip
refactor(handler): move traits
Diffstat (limited to 'src/handler.rs')
-rw-r--r--src/handler.rs44
1 files changed, 8 insertions, 36 deletions
diff --git a/src/handler.rs b/src/handler.rs
index 88dafc8..63c353c 100644
--- a/src/handler.rs
+++ b/src/handler.rs
@@ -16,40 +16,12 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use crate::{
- response::Response,
- returnable,
- returnable::{CallbackContext, RouteContext},
+mod hooks;
+mod partial;
+mod response;
+
+pub use self::{
+ hooks::{PostRouteCallback, PreRouteCallback},
+ partial::Partial,
+ response::{ErrorResponse, RouteResponse},
};
-
-pub trait RouteResponse:
- FnMut(RouteContext<'_>) -> Response + Send + Sync
-{
-}
-
-impl<T> RouteResponse for T where T: FnMut(RouteContext<'_>) -> 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 trait Callback: FnMut(CallbackContext<'_>) + Send + Sync {}
-
-impl<T> Callback for T where T: FnMut(CallbackContext<'_>) + Send + Sync {}
-
-pub trait CleanupCallback:
- FnMut(CallbackContext<'_>, &mut Response) + Send + Sync
-{
-}
-
-impl<T> CleanupCallback for T where T: FnMut(CallbackContext<'_>, &mut Response) + Send + Sync
-{}
-
-pub trait Partial: FnMut(RouteContext<'_>) -> String + Send + Sync {}
-
-impl<T> Partial for T where T: FnMut(RouteContext<'_>) -> String + Send + Sync {}