From dfa35daf0fecacc1bf90b399a6d9f485e80d0ca0 Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Sat, 10 Aug 2024 15:32:29 +0000
Subject: [PATCH] refactor: Split the finders into several modules
Signed-off-by: Awiteb
---
src/finder.rs | 340 ------------------------------------
src/finder/form_finder.rs | 173 ++++++++++++++++++
src/finder/header_finder.rs | 162 +++++++++++++++++
src/finder/mod.rs | 43 +++++
4 files changed, 378 insertions(+), 340 deletions(-)
delete mode 100644 src/finder.rs
create mode 100644 src/finder/form_finder.rs
create mode 100644 src/finder/header_finder.rs
create mode 100644 src/finder/mod.rs
diff --git a/src/finder.rs b/src/finder.rs
deleted file mode 100644
index f26cd71..0000000
--- a/src/finder.rs
+++ /dev/null
@@ -1,340 +0,0 @@
-// Copyright (c) 2024, Awiteb
-// A captcha middleware for Salvo framework.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-use salvo_core::http::header::HeaderName;
-use salvo_core::http::Request;
-
-/// Trait to find the captcha token and answer from the request.
-pub trait CaptchaFinder: Send + Sync {
- /// Find the captcha token from the request.
- ///
- /// ### Returns
- /// - None: If the token is not found
- /// - Some(None): If the token is found but is invalid (e.g. not a valid string)
- /// - Some(Some(token)): If the token is found
- fn find_token(
- &self,
- req: &mut Request,
- ) -> impl std::future::Future