pub struct QueryStringConfig { /* private fields */ }
Expand description
QueryString extractor configuration
§Example
use actix_web::{error, web, App, FromRequest, HttpResponse};
use serde::Deserialize;
use serde_querystring_actix::{QueryString, QueryStringConfig, ParseMode};
#[derive(Deserialize)]
struct Info {
username: String,
}
/// deserialize `Info` from request's querystring
async fn index(info: QueryString<Info>) -> String {
format!("Welcome {}!", info.username)
}
fn main() {
let app = App::new().service(
web::resource("/index.html").app_data(
// change query extractor configuration
QueryStringConfig::default()
.parse_mode(ParseMode::Brackets) // <- choose the parsing mode
.error_handler(|err, req| { // <- create custom error response
error::InternalError::from_response(
err, HttpResponse::Conflict().finish()).into()
})
)
.route(web::post().to(index))
);
}
Implementations§
Source§impl QueryStringConfig
impl QueryStringConfig
Sourcepub fn error_handler<F>(self, f: F) -> Self
pub fn error_handler<F>(self, f: F) -> Self
Set custom error handler
pub fn parse_mode(self, mode: ParseMode) -> Self
Trait Implementations§
Source§impl Clone for QueryStringConfig
impl Clone for QueryStringConfig
Source§fn clone(&self) -> QueryStringConfig
fn clone(&self) -> QueryStringConfig
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 moreAuto Trait Implementations§
impl Freeze for QueryStringConfig
impl !RefUnwindSafe for QueryStringConfig
impl Send for QueryStringConfig
impl Sync for QueryStringConfig
impl Unpin for QueryStringConfig
impl !UnwindSafe for QueryStringConfig
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