[−][src]Struct jsonrpc_http_server::ServerBuilder
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, [src]
S::Future: Unpin,
S::CallFuture: Unpin,
M: Unpin,
pub fn new<T>(handler: T) -> Self where
T: Into<MetaIoHandler<M, S>>, [src]
T: Into<MetaIoHandler<M, S>>,
Creates new ServerBuilder for given IoHandler.
By default:
- Server is not sending any CORS headers.
- Server is validating
Hostheader.
impl<M: Metadata, S: Middleware<M>> ServerBuilder<M, S> where
S::Future: Unpin,
S::CallFuture: Unpin,
M: Unpin, [src]
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>, [src]
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
Hostheader.
pub fn event_loop_executor(mut self: Self, executor: TaskExecutor) -> Self[src]
Utilize existing event loop executor to poll RPC results.
Applies only to 1 of the threads. Other threads will spawn their own Event Loops.
pub fn rest_api(mut self: Self, rest_api: RestApi) -> Self[src]
Enable the REST -> RPC converter.
Allows you to invoke RPCs by sending POST /<method>/<param1>/<param2> requests
(with no body). Disabled by default.
pub fn health_api<A, B, T>(mut self: Self, health_api: T) -> Self where
T: Into<Option<(A, B)>>,
A: Into<String>,
B: Into<String>, [src]
T: Into<Option<(A, B)>>,
A: Into<String>,
B: Into<String>,
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>).
pub fn keep_alive(mut self: Self, val: bool) -> Self[src]
Enables or disables HTTP keep-alive.
Default is true.
pub fn threads(mut self: Self, threads: usize) -> Self[src]
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.
pub fn cors(
mut self: Self,
cors_domains: DomainsValidation<AccessControlAllowOrigin>
) -> Self[src]
mut self: Self,
cors_domains: DomainsValidation<AccessControlAllowOrigin>
) -> Self
Configures a list of allowed CORS origins.
pub fn cors_max_age<T: Into<Option<u32>>>(
mut self: Self,
cors_max_age: T
) -> Self[src]
mut self: Self,
cors_max_age: T
) -> Self
Configure CORS AccessControlMaxAge header returned.
Informs the client that the CORS preflight request is not necessary for cors_max_age seconds.
Disabled by default.
pub fn cors_allow_headers(
mut self: Self,
allowed_headers: AccessControlAllowHeaders
) -> Self[src]
mut self: Self,
allowed_headers: AccessControlAllowHeaders
) -> Self
Configure the CORS AccessControlAllowHeaders header which are allowed.
pub fn request_middleware<T: RequestMiddleware>(
mut self: Self,
middleware: T
) -> Self[src]
mut self: Self,
middleware: T
) -> Self
Configures request middleware
pub fn meta_extractor<T: MetaExtractor<M>>(mut self: Self, extractor: T) -> Self[src]
Configures metadata extractor
pub fn allow_only_bind_host(mut self: Self) -> Self[src]
Allow connections only with Host header set to binding address.
pub fn allowed_hosts(
mut self: Self,
allowed_hosts: DomainsValidation<Host>
) -> Self[src]
mut self: Self,
allowed_hosts: DomainsValidation<Host>
) -> Self
Specify a list of valid Host headers. Binding address is allowed automatically.
pub fn max_request_body_size(mut self: Self, val: usize) -> Self[src]
Sets the maximum size of a request body in bytes (default is 5 MiB).
pub fn start_http(self, addr: &SocketAddr) -> Result<Server>[src]
Start this JSON-RPC HTTP server trying to bind to specified SocketAddr.
Auto Trait Implementations
impl<M = (), S = Noop> !RefUnwindSafe for ServerBuilder<M, S>[src]
impl<M, S> Send for ServerBuilder<M, S>[src]
impl<M, S> Sync for ServerBuilder<M, S>[src]
impl<M, S> Unpin for ServerBuilder<M, S>[src]
impl<M = (), S = Noop> !UnwindSafe for ServerBuilder<M, S>[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T> Instrument for T[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>[src]
pub fn in_current_span(self) -> Instrumented<Self>[src]
impl<T> Instrument for T[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>[src]
pub fn in_current_span(self) -> Instrumented<Self>[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,