Struct jsonrpc_http_server::ServerBuilder
[−]
[src]
pub struct ServerBuilder<M: Metadata = (), S: Middleware<M> = NoopMiddleware> { /* fields omitted */ }
Convenient JSON-RPC HTTP Server builder.
Methods
impl<M: Metadata, S: Middleware<M>> ServerBuilder<M, S>
[src]
fn new<T>(handler: T) -> Self where
T: Into<MetaIoHandler<M, S>>,
T: Into<MetaIoHandler<M, S>>,
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 event_loop_remote(self, remote: Remote) -> Self
Utilize existing event loop remote to poll RPC results. Applies only to 1 of the threads. Other threads will spawn their own Event Loops.
fn keep_alive(self, val: bool) -> Self
Sets Enables or disables HTTP keep-alive. Default is true.
fn threads(self, threads: usize) -> Self
Sets number of threads of the server to run.
Panics when set to 0
.
fn cors(self, cors_domains: DomainsValidation<AccessControlAllowOrigin>) -> Self
Configures a list of allowed CORS origins.
fn request_middleware<T: RequestMiddleware>(self, middleware: T) -> Self
Configures request middleware
fn meta_extractor<T: MetaExtractor<M>>(self, extractor: T) -> Self
Configures metadata extractor
fn allow_only_bind_host(self) -> Self
Allow connections only with Host
header set to binding address.
fn allowed_hosts(self, allowed_hosts: DomainsValidation<Host>) -> Self
Specify a list of valid Host
headers. Binding address is allowed automatically.
fn start_http(self, addr: &SocketAddr) -> ServerResult
Start this JSON-RPC HTTP server trying to bind to specified SocketAddr
.