pub fn new(origins_str: String) -> Option<Arc<Configured>> {
    let cors = Cors::new();
    let cors = if origins_str.is_empty() {
        None
    } else if origins_str == "*" {
        Some(cors.allow_any_origin().allow_methods(vec!["GET", "HEAD"]))
    } else {
        let hosts = origins_str.split(',').map(|s| s.trim()).collect::<Vec<_>>();
        if hosts.is_empty() {
            None
        } else {
            Some(cors.allow_origins(hosts).allow_methods(vec!["GET", "HEAD"]))
        }
    };
    if cors.is_some() {
        tracing::info!(
            "enabled=true, allow_methods=[GET, HEAD], allow_origins={}",
            origins_str
        );
    }
    Cors::build(cors)
}
/// It builds a new CORS instance.
It builds a new CORS instance.
It builds a new CORS instance .
pub fn new(origins_str: String) -> Option<Arc<Configured>> {
    let cors = Cors::new();
    let cors = if origins_str.is_empty() {
        None
    } else if origins_str == "*" {
        Some(cors.allow_any_origin().allow_methods(vec!["GET", "HEAD"]))
    } else {
        let hosts = origins_str.split(',').map(|s| s.trim()).collect::<Vec<_>>();
        if hosts.is_empty() {
            None
        } else {
            Some(cors.allow_origins(hosts).allow_methods(vec!["GET", "HEAD"]))
        }
    };
    if cors.is_some() {
        tracing::info!(
            "enabled=true, allow_methods=[GET, HEAD], allow_origins={}",
            origins_str
        );
    }
    Cors::build(cors)
}
pub fn new ( origins_str : String ) -> Option < Arc < Configured > > { let cors = Cors :: new ( ) ; let cors = if origins_str . is_empty ( ) { None } else if origins_str == " " { Some ( cors . allow_any_origin ( ) . allow_methods ( vec ! [ " " " " ] ) ) } else { let hosts = origins_str . split ( ',' ) . map ( | s | s . trim ( ) ) . collect :: < Vec < _ > > ( ) ; if hosts . is_empty ( ) { None } else { Some ( cors . allow_origins ( hosts ) . allow_methods ( vec ! [ " " " " ] ) ) } } ; if cors . is_some ( ) { tracing :: info ! ( " " origins_str ) ; } Cors :: build ( cors ) }
It builds a new CORS instance.
It builds a new CORS instance .
origins_str
String
origins_str
String