Allow specifying extra cors headers for dapps (#4710)

This commit is contained in:
Tomasz Drwięga
2017-03-07 17:33:28 +01:00
committed by Arkadiy Paronyan
parent ae3f85bd5b
commit 4868f758bf
8 changed files with 76 additions and 10 deletions

View File

@@ -39,7 +39,11 @@ pub struct RestApi {
impl RestApi {
pub fn new(cors_domains: Vec<String>, endpoints: Arc<Endpoints>, fetcher: Arc<Fetcher>) -> Box<Endpoint> {
Box::new(RestApi {
cors_domains: Some(cors_domains.into_iter().map(AccessControlAllowOrigin::Value).collect()),
cors_domains: Some(cors_domains.into_iter().map(|domain| match domain.as_ref() {
"all" | "*" | "any" => AccessControlAllowOrigin::Any,
"null" => AccessControlAllowOrigin::Null,
other => AccessControlAllowOrigin::Value(other.into()),
}).collect()),
endpoints: endpoints,
fetcher: fetcher,
})