actix_multipart_extract/
config.rs

1use actix_web::HttpResponse;
2
3use crate::MultipartError;
4
5type MultipartErrorHandler = Box<dyn Fn(MultipartError) -> HttpResponse + Send + Sync + 'static>;
6
7/// Config for Multipart data, insert with [`actix_web::App::app_data`] to actix
8pub struct MultipartConfig {
9    pub error_handler: Option<MultipartErrorHandler>,
10}
11
12impl MultipartConfig {
13    pub fn set_error_handler<F>(mut self, error_handler: F) -> Self
14    where
15        F: Fn(MultipartError) -> HttpResponse + Send + Sync + 'static,
16    {
17        self.error_handler = Some(Box::new(error_handler));
18        self
19    }
20}
21
22impl Default for MultipartConfig {
23    fn default() -> Self {
24        Self {
25            error_handler: None,
26        }
27    }
28}