pub struct Cors { /* fields omitted */ }
Middleware
for Cross-origin resource sharing support
The Cors struct contains the settings for CORS requests to be validated and
for responses to be generated.
Create CorsBuilder for a specified application.
use actix_web::middleware::cors::Cors;
use actix_web::{http, App, HttpResponse};
fn main() {
let app = App::new().configure(
|app| {
Cors::for_app(app)
.allowed_origin("https://www.rust-lang.org/")
.resource("/resource", |r| {
r.method(http::Method::GET).f(|_| HttpResponse::Ok());
})
.register()
},
);
}
This method register cors middleware with resource and
adds route for OPTIONS preflight requests.
It is possible to register Cors middleware with
ResourceHandler::middleware()
method, but in that case Cors
middleware wont be able to handle OPTIONS requests.
Method is called when request is ready. It may return future, which should resolve before next middleware get called. Read more
Method is called when handler returns response, but before sending http message to peer. Read more
Method is called after body stream get sent to peer.
Performs copy-assignment from source
. Read more
Returns the "default value" for a type. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
impl<T> Clear for T where T: InitializableFromZeroed + ?Sized, | |
Completely overwrites this value.
impl<T> InitializableFromZeroed for T where T: Default, | |
Called to initialize a place to a valid value, after it is set to all-bits-zero. Read more