pub struct QsQueryConfig { /* private fields */ }Expand description
Configuration for query and form extractors.
Allows customization of error handling and serialization parameters
for both QsQuery and QsForm extractors.
use actix_web::{error, web, App, FromRequest, HttpResponse};
use serde::Deserialize;
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 duplicate of the value. Read more
1.0.0 (const: unstable) · 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 !RefUnwindSafe for QsQueryConfig
impl !UnwindSafe for QsQueryConfig
impl Freeze for QsQueryConfig
impl Send for QsQueryConfig
impl Sync for QsQueryConfig
impl Unpin for QsQueryConfig
impl UnsafeUnpin 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