pub struct QsQueryConfig { /* private fields */ }
Expand description
Query extractor configuration (serde_qs based).
use actix_web::{error, web, App, FromRequest, HttpResponse};
use actix_web_validator::QsQueryConfig;
use serde_qs::actix::QsQuery;
use serde_qs::Config as QsConfig;
use serde::Deserialize;
#[derive(Deserialize)]
struct Info {
username: String,
}
/// deserialize `Info` from request's querystring
async fn index(info: QsQuery<Info>) -> String {
format!("Welcome {}!", info.username)
}
fn main() {
let qs_query_config = QsQueryConfig::default()
.error_handler(|err, req| { // <- create custom error response
error::InternalError::from_response(err, HttpResponse::Conflict().finish()).into()
})
.qs_config(QsConfig::default());
let app = App::new().service(
web::resource("/index.html").app_data(qs_query_config)
.route(web::post().to(index))
);
}
Implementations§
Source§impl QsQueryConfig
impl QsQueryConfig
Trait Implementations§
Source§impl Default for QsQueryConfig
impl Default for QsQueryConfig
Source§fn default() -> QsQueryConfig
fn default() -> QsQueryConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for QsQueryConfig
impl !RefUnwindSafe for QsQueryConfig
impl Send for QsQueryConfig
impl Sync for QsQueryConfig
impl Unpin for QsQueryConfig
impl !UnwindSafe for QsQueryConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more