Struct actix_web_validator::QueryConfig [−][src]
pub struct QueryConfig { pub ehandler: Option<Arc<dyn Fn(Error, &HttpRequest) -> Error + Send + Sync>>, }
Expand description
Query extractor configuration.
Example
use actix_web::{error, web, App, FromRequest, HttpResponse}; use serde::Deserialize; use actix_web_validator::{Query, QueryConfig}; use validator::Validate; #[derive(Deserialize, Validate)] struct Info { #[validate(length(min = 1))] username: String, } /// deserialize `Info` from request's querystring async fn index(info: Query<Info>) -> String { format!("Welcome {}!", info.username) } fn main() { let app = App::new().service( web::resource("/index.html") .app_data( // change query extractor configuration Query::<Info>::configure(|cfg| { cfg.error_handler(|err, req| { // <- create custom error response error::InternalError::from_response( err, HttpResponse::Conflict().finish()).into() }) })) .route(web::post().to(index)) ); }
Fields
ehandler: Option<Arc<dyn Fn(Error, &HttpRequest) -> Error + Send + Sync>>
Implementations
pub fn error_handler<F>(self, f: F) -> Self where
F: Fn(Error, &HttpRequest) -> Error + Send + Sync + 'static,
[src]
pub fn error_handler<F>(self, f: F) -> Self where
F: Fn(Error, &HttpRequest) -> Error + Send + Sync + 'static,
[src]Set custom error handler
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for QueryConfig
impl Send for QueryConfig
impl Sync for QueryConfig
impl Unpin for QueryConfig
impl !UnwindSafe for QueryConfig
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V