Struct ethcore_rpc::ServerBuilder
[−]
pub struct ServerBuilder<M = ()> where M: Metadata { /* fields omitted */ }
Convenient JSON-RPC HTTP Server builder.
Methods
impl<M> ServerBuilder<M> where M: Metadata
fn new<T>(handler: T) -> ServerBuilder<M> where T: Into<MetaIoHandler<M>>
Creates new ServerBuilder
for given IoHandler
.
If you want to re-use the same handler in couple places
see with_remote
function.
By default:
1. Server is not sending any CORS headers.
2. Server is validating Host
header.
fn with_rpc_handler(handler: RpcHandler<M>) -> ServerBuilder<M>
Creates new ServerBuilder
given access to the event loop Remote
.
By default:
1. Server is not sending any CORS headers.
2. Server is validating Host
header.
fn panic_handler<F>(self, handler: F) -> ServerBuilder<M> where F: Fn() -> () + Send + 'static
Sets handler invoked in case of server panic.
fn cors(self,
cors_domains: DomainsValidation<AccessControlAllowOrigin>)
-> ServerBuilder<M>
cors_domains: DomainsValidation<AccessControlAllowOrigin>)
-> ServerBuilder<M>
Configures a list of allowed CORS origins.
fn meta_extractor(self,
extractor: Arc<HttpMetaExtractor<M> + 'static>)
-> ServerBuilder<M>
extractor: Arc<HttpMetaExtractor<M> + 'static>)
-> ServerBuilder<M>
Configures metadata extractor
fn allow_only_bind_host(self) -> ServerBuilder<M>
Allow connections only with Host
header set to binding address.
fn allowed_hosts(self,
allowed_hosts: DomainsValidation<String>)
-> ServerBuilder<M>
allowed_hosts: DomainsValidation<String>)
-> ServerBuilder<M>
Specify a list of valid Host
headers. Binding address is allowed automatically.
fn start_http(self, addr: &SocketAddr) -> Result<Server, RpcServerError>
Start this JSON-RPC HTTP server trying to bind to specified SocketAddr
.