Struct actix_web::dev::PathConfig
source · pub struct PathConfig<S> { /* private fields */ }
Expand description
Path extractor configuration
use actix_web::{error, http, App, HttpResponse, Path, Result};
/// deserialize `Info` from request's body, max payload size is 4kb
fn index(info: Path<(u32, String)>) -> Result<String> {
Ok(format!("Welcome {}!", info.1))
}
fn main() {
let app = App::new().resource("/index.html/{id}/{name}", |r| {
r.method(http::Method::GET).with_config(index, |cfg| {
cfg.0.error_handler(|err, req| {
// <- create custom error response
error::InternalError::from_response(err, HttpResponse::Conflict().finish()).into()
});
})
});
}
Implementations
sourceimpl<S> PathConfig<S>
impl<S> PathConfig<S>
sourcepub fn error_handler<F>(&mut self, f: F) -> &mut Selfwhere
F: Fn(Error, &HttpRequest<S>) -> Error + 'static,
pub fn error_handler<F>(&mut self, f: F) -> &mut Selfwhere
F: Fn(Error, &HttpRequest<S>) -> Error + 'static,
Set custom error handler
sourcepub fn disable_decoding(&mut self) -> &mut Self
pub fn disable_decoding(&mut self) -> &mut Self
Disable decoding of URL encoded special charaters from the path
Trait Implementations
Auto Trait Implementations
impl<S> !RefUnwindSafe for PathConfig<S>
impl<S> !Send for PathConfig<S>
impl<S> !Sync for PathConfig<S>
impl<S> Unpin for PathConfig<S>
impl<S> !UnwindSafe for PathConfig<S>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more