diff options
| author | Fuwn <[email protected]> | 2023-04-03 02:47:11 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-03 02:47:11 +0000 |
| commit | 79ad55e1e0fe746a635e6814fbf048437c2d50ee (patch) | |
| tree | 12c395e03accf4a4a115b24946760bcae5d0d148 /src/handler.rs | |
| parent | feat(router): GET RID OF DIRTY BOXES (diff) | |
| download | windmark-79ad55e1e0fe746a635e6814fbf048437c2d50ee.tar.xz windmark-79ad55e1e0fe746a635e6814fbf048437c2d50ee.zip | |
refactor(handler): trait-based response
Diffstat (limited to 'src/handler.rs')
| -rw-r--r-- | src/handler.rs | 10 |
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>; |