pub struct PathConfig { /* private fields */ }Expand description
Path extractor configuration
use actix_web::web::PathConfig;
use actix_web::{error, web, App, FromRequest, HttpResponse};
use serde::Deserialize;
#[derive(Deserialize, Debug)]
enum Folder {
#[serde(rename = "inbox")]
Inbox,
#[serde(rename = "outbox")]
Outbox,
}
// deserialize `Info` from request's path
async fn index(folder: web::Path<Folder>) -> String {
format!("Selected folder: {:?}!", folder)
}
let app = App::new().service(
web::resource("/messages/{folder}")
.app_data(PathConfig::default().error_handler(|err, req| {
error::InternalError::from_response(
err,
HttpResponse::Conflict().into(),
)
.into()
}))
.route(web::post().to(index)),
);Implementations§
Source§impl PathConfig
impl PathConfig
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 PathConfig
impl Clone for PathConfig
Auto Trait Implementations§
impl !RefUnwindSafe for PathConfig
impl !UnwindSafe for PathConfig
impl Freeze for PathConfig
impl Send for PathConfig
impl Sync for PathConfig
impl Unpin for PathConfig
impl UnsafeUnpin for PathConfig
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