diff options
| author | Fuwn <[email protected]> | 2023-04-03 03:13:00 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-03 03:13:00 +0000 |
| commit | 86ef3091353846d2aa9fa2d6c3da35ddf0dd3d39 (patch) | |
| tree | 3f76d86bd819066fd3e7bdde9fa56ef671d29b6e /src/handler/hooks | |
| parent | refactor(handler): misc. rename (diff) | |
| download | windmark-86ef3091353846d2aa9fa2d6c3da35ddf0dd3d39.tar.xz windmark-86ef3091353846d2aa9fa2d6c3da35ddf0dd3d39.zip | |
refactor(handler): move traits
Diffstat (limited to 'src/handler/hooks')
| -rw-r--r-- | src/handler/hooks/post_route.rs | 28 | ||||
| -rw-r--r-- | src/handler/hooks/pre_route.rs | 24 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/handler/hooks/post_route.rs b/src/handler/hooks/post_route.rs new file mode 100644 index 0000000..eea0128 --- /dev/null +++ b/src/handler/hooks/post_route.rs @@ -0,0 +1,28 @@ +// This file is part of Windmark <https://github.com/gemrest/windmark>. +// Copyright (C) 2022-2022 Fuwn <[email protected]> +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +// Copyright (C) 2022-2022 Fuwn <[email protected]> +// SPDX-License-Identifier: GPL-3.0-only + +use crate::{context::HookContext, Response}; + +#[allow(clippy::module_name_repetitions)] +pub trait PostRouteHook: + FnMut(HookContext<'_>, &mut Response) + Send + Sync +{ +} + +impl<T> PostRouteHook for T where T: FnMut(HookContext<'_>, &mut Response) + Send + Sync +{} diff --git a/src/handler/hooks/pre_route.rs b/src/handler/hooks/pre_route.rs new file mode 100644 index 0000000..13f4482 --- /dev/null +++ b/src/handler/hooks/pre_route.rs @@ -0,0 +1,24 @@ +// This file is part of Windmark <https://github.com/gemrest/windmark>. +// Copyright (C) 2022-2022 Fuwn <[email protected]> +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +// Copyright (C) 2022-2022 Fuwn <[email protected]> +// SPDX-License-Identifier: GPL-3.0-only + +use crate::context::HookContext; + +#[allow(clippy::module_name_repetitions)] +pub trait PreRouteHook: FnMut(HookContext<'_>) + Send + Sync {} + +impl<T> PreRouteHook for T where T: FnMut(HookContext<'_>) + Send + Sync {} |