1use crate::{request::RequestBody, response::ResponseWriter};
2use async_trait::async_trait;
3use std::collections::HashMap;
4use std::error::Error as StdError;
5
6#[derive(Hash, Eq, PartialEq, Debug, Clone, Copy)]
7pub enum Method {
8 GET,
9 POST,
10 PUT,
11 PATCH,
12 DELETE,
13 OPTIONS,
14 HEAD,
15 TRACE,
16}
17
18#[derive(Eq, PartialEq)]
19#[allow(dead_code)]
20pub enum Mode {
21 Http1,
22 Http2,
23}
24
25#[allow(dead_code)]
26#[derive(Debug, Clone)]
27pub struct FormFile {
28 pub field_name: String,
29 pub file_name: String,
30 pub content_type: String,
31 pub temp_path: String,
32}
33
34#[derive(Debug, Clone)]
35pub struct FormData {
36 pub files: Vec<FormFile>,
37 pub fields: HashMap<String, String>,
38}
39
40#[async_trait]
41pub trait Middleware: Send + Sync {
42 async fn run(&self, req: &mut RequestBody, res: &mut ResponseWriter);
43}
44
45#[async_trait]
46pub trait ErrorHandler: Send + Sync {
47 async fn run(&self, msg: String, res: &mut ResponseWriter);
48}
49
50#[async_trait]
51pub trait Handler: Send + Sync {
52 async fn run(&self, req: &mut RequestBody, res: &mut ResponseWriter);
53}
54
55pub type BoltError = Box<dyn StdError + Send + Sync>;
56
57#[allow(dead_code)]
58pub type BoltResult<T> = Result<T, BoltError>;