pub struct XmlConfig { /* private fields */ }
Expand description
XML extractor configuration
§Example
use actix_web::{error, web, App, FromRequest, HttpResponse};
use actix_xml::{Xml, XmlConfig};
use serde::Deserialize;
#[derive(Deserialize)]
struct Info {
username: String,
}
/// deserialize `Info` from request's body, max payload size is 4kb
async fn index(info: Xml<Info>) -> String {
format!("Welcome {}!", info.username)
}
fn main() {
let app = App::new().service(
web::resource("/index.html")
.app_data(
// Json extractor configuration for this resource.
XmlConfig::default()
.limit(4096) // Limit request payload size
.content_type(|mime| { // <- accept text/plain content type
mime.type_() == mime::TEXT && mime.subtype() == mime::PLAIN
})
)
.route(web::post().to(index))
);
}
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for XmlConfig
impl !RefUnwindSafe for XmlConfig
impl Send for XmlConfig
impl Sync for XmlConfig
impl Unpin for XmlConfig
impl !UnwindSafe for XmlConfig
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