Struct jsonrpc_http_server::ServerBuilder [−][src]
pub struct ServerBuilder<M: Metadata = (), S: Middleware<M> = Noop> { /* fields omitted */ }
Expand description
Convenient JSON-RPC HTTP Server builder.
Implementations
impl<M: Metadata + Default, S: Middleware<M>> ServerBuilder<M, S> where
S::Future: Unpin,
S::CallFuture: Unpin,
M: Unpin,
impl<M: Metadata + Default, S: Middleware<M>> ServerBuilder<M, S> where
S::Future: Unpin,
S::CallFuture: Unpin,
M: Unpin,
Creates new ServerBuilder
for given IoHandler
.
By default:
- Server is not sending any CORS headers.
- Server is validating
Host
header.
impl<M: Metadata, S: Middleware<M>> ServerBuilder<M, S> where
S::Future: Unpin,
S::CallFuture: Unpin,
M: Unpin,
impl<M: Metadata, S: Middleware<M>> ServerBuilder<M, S> where
S::Future: Unpin,
S::CallFuture: Unpin,
M: Unpin,
pub fn with_meta_extractor<T, E>(handler: T, extractor: E) -> Self where
T: Into<MetaIoHandler<M, S>>,
E: MetaExtractor<M>,
pub fn with_meta_extractor<T, E>(handler: T, extractor: E) -> Self where
T: Into<MetaIoHandler<M, S>>,
E: MetaExtractor<M>,
Creates new ServerBuilder
for given IoHandler
.
By default:
- Server is not sending any CORS headers.
- Server is validating
Host
header.
Utilize existing event loop executor to poll RPC results.
Applies only to 1 of the threads. Other threads will spawn their own Event Loops.
Enable the REST -> RPC converter.
Allows you to invoke RPCs by sending POST /<method>/<param1>/<param2>
requests
(with no body). Disabled by default.
Enable health endpoint.
Allows you to expose one of the methods under GET /<path>
The method will be invoked with no parameters.
Error returned from the method will be converted to status 500
response.
Expects a tuple with (<path>, <rpc-method-name>)
.
Enables or disables HTTP keep-alive.
Default is true.
Sets number of threads of the server to run.
Panics when set to 0
.
The first thread will use provided Executor
instance
and all other threads will use UninitializedExecutor
to spawn
a new runtime for futures.
So it’s also possible to run a multi-threaded server by
passing the default tokio::runtime
executor to this builder
and setting threads
to 1.
Configures a list of allowed CORS origins.
Configure CORS AccessControlMaxAge
header returned.
Informs the client that the CORS preflight request is not necessary for cors_max_age
seconds.
Disabled by default.
Configure the CORS AccessControlAllowHeaders
header which are allowed.
Configures request middleware
Configures metadata extractor
Allow connections only with Host
header set to binding address.
Specify a list of valid Host
headers. Binding address is allowed automatically.
Sets the maximum size of a request body in bytes (default is 5 MiB).
Start this JSON-RPC HTTP server trying to bind to specified SocketAddr
.
Auto Trait Implementations
impl<M = (), S = Noop> !RefUnwindSafe for ServerBuilder<M, S>
impl<M, S> Send for ServerBuilder<M, S>
impl<M, S> Sync for ServerBuilder<M, S>
impl<M, S> Unpin for ServerBuilder<M, S>
impl<M = (), S = Noop> !UnwindSafe for ServerBuilder<M, S>