Struct serde_qs::actix::QsQueryConfig
source · pub struct QsQueryConfig { /* private fields */ }
Expand description
Query extractor configuration
use actix_web::{error, web, App, FromRequest, HttpResponse};
use serde_qs::actix::QsQuery;
use serde_qs::Config as QsConfig;
use serde_qs::actix::QsQueryConfig;
#[derive(Deserialize)]
struct Info {
username: String,
}
/// deserialize `Info` from request's querystring
async fn index(info: QsQuery<Info>) -> HttpResponse {
HttpResponse::Ok().body(
format!("Welcome {}!", info.username)
)
}
fn main() {
let qs_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_config)
.route(web::post().to(index))
);
}
Implementations§
source§impl QsQueryConfig
impl QsQueryConfig
sourcepub fn error_handler<F>(self, f: F) -> Self
pub fn error_handler<F>(self, f: F) -> Self
Set custom error handler
Trait Implementations§
source§impl Clone for QsQueryConfig
impl Clone for QsQueryConfig
source§fn clone(&self) -> QsQueryConfig
fn clone(&self) -> QsQueryConfig
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§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