Merge pull request #1247 from ethcore/rpc-cors-fix
Fixing CORS settings for special values: * & null.
This commit is contained in:
commit
e633cd2f75
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -606,7 +606,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-http-server"
|
name = "jsonrpc-http-server"
|
||||||
version = "5.1.0"
|
version = "5.1.0"
|
||||||
source = "git+https://github.com/ethcore/jsonrpc-http-server.git#77dcac785c02c3a7622d36aa635ee80d63d0b20c"
|
source = "git+https://github.com/ethcore/jsonrpc-http-server.git#6117b1d77b5a60d6fa2dc884f12aa7f5fd4585ca"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hyper 0.9.3 (git+https://github.com/ethcore/hyper)",
|
"hyper 0.9.3 (git+https://github.com/ethcore/hyper)",
|
||||||
"jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -75,7 +75,11 @@ impl RpcServer {
|
|||||||
/// Start http server asynchronously and returns result with `Server` handle on success or an error.
|
/// Start http server asynchronously and returns result with `Server` handle on success or an error.
|
||||||
pub fn start_http(&self, addr: &SocketAddr, cors_domains: Vec<String>) -> Result<Server, RpcServerError> {
|
pub fn start_http(&self, addr: &SocketAddr, cors_domains: Vec<String>) -> Result<Server, RpcServerError> {
|
||||||
let cors_domains = cors_domains.into_iter()
|
let cors_domains = cors_domains.into_iter()
|
||||||
.map(jsonrpc_http_server::AccessControlAllowOrigin::Value)
|
.map(|v| match v.as_str() {
|
||||||
|
"*" => jsonrpc_http_server::AccessControlAllowOrigin::Any,
|
||||||
|
"null" => jsonrpc_http_server::AccessControlAllowOrigin::Null,
|
||||||
|
v => jsonrpc_http_server::AccessControlAllowOrigin::Value(v.into()),
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
Server::start(addr, self.handler.clone(), cors_domains)
|
Server::start(addr, self.handler.clone(), cors_domains)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user