cors.rs
Rust test marker or harnessimports http
SHA-256463d58f94028cfdac9481ce93b56166c208941d17595ac700c498a5408315621
MaleculeMd₂(In₉Pa)
Evidence
1//! Cross-origin resource sharing (CORS) for Actix applications
2//!
3//! CORS middleware could be used with application and with resource.
4//! First you need to construct CORS middleware instance.
5//!
6//! To construc …
8:54… .build) to start building.
9//! 2. Use any of the builder methods to set fields in the backend.
10//! 3. Call [finish](struct.Cors.html#method.f …
48:28… ically handle *OPTIONS* preflight request.
49use std::collections::HashSet;
50use std::iter::FromIterator;
51use std::rc::Rc;
52
53use http::header::{self, HeaderName, HeaderValue};
54use http::{self, HttpTryFrom, Method, StatusCode, Uri};
55
56use application::App;
57use error::{ResponseError, Result};
58use httpmessage::HttpMessage;
59use httprequest::HttpRequest;
60use httpresponse::HttpResponse;
61use middleware::{Middleware, Response, Started};
62use resource::Resource;
63use router::ResourceDef;
64use server::Request;
65
66/// A set of errors that can occur during processing CORS
67#[derive(Debug, Fail)]
68pub enum CorsError {
69 /// The HTTP r …
⋯5 lines
883}
884
885#[cfg(test)]
886mod tests {
887 use super::*;
888 use test::{self, TestRequest};
889
890 impl Started {
891 fn is_done(&self) -> bool {
892 match *self {
893 …
908:4… _ => panic!(),
909 }
910 }
911 }
912
913 #[test]
914 #[should_panic(expected = "Credentials are allowed, but the Origin is set to")]
915 fn cors_validates_illegal_allow_crede …