Expand description
jsonrpc http server.
use jsonrpc_core::*;
use jsonrpc_http_server::*;
fn main() {
let mut io = IoHandler::new();
io.add_sync_method("say_hello", |_: Params| {
Ok(Value::String("hello".to_string()))
});
let _server = ServerBuilder::new(io)
.start_http(&"127.0.0.1:3030".parse().unwrap())
.expect("Unable to start RPC server");
_server.wait();
}
Re-exports§
pub use hyper;
pub use jsonrpc_core;
pub use crate::server_utils::tokio;
Modules§
- cors
- CORS handling utility functions
Structs§
- Close
Handle - Handle used to close the server. Can be cloned and passed around to different threads and be used
to close a server that is
wait()
ing. - Host
- Host type
- Origin
- Request Origin
- Response
- Simple server response structure
- Rpc
- RPC Handler bundled with metadata extractor.
- Server
- jsonrpc http server instance
- Server
Builder - Convenient JSON-RPC HTTP Server builder.
- Server
Handler - jsonrpc http request handler.
- Suspendable
Stream Incoming
is a stream of incoming sockets Polling the stream may return a temporary io::Error (for instance if we can’t open the connection because of “too many open files” limit) we use for_each combinator which:- WeakRpc
- A weak handle to the RPC server.
Enums§
- Access
Control Allow Origin - Origins allowed to access
- Allow
Cors - CORS response headers
- Domains
Validation - Specifies if domains should be validated.
- Request
Middleware Action - Action undertaken by a middleware.
- RestApi
- REST -> RPC converter state.
Traits§
- Meta
Extractor - Extracts metadata from the HTTP request.
- Request
Middleware - Allows to intercept request and handle it differently.
Functions§
- cors_
allow_ headers - Returns the CORS AllowHeaders header that should be returned with that request.
- cors_
allow_ origin - Returns a CORS AllowOrigin header that should be returned with that request.
- is_
host_ allowed - Returns
true
if Host header in request matches a list of allowed hosts.
Type Aliases§
- Task
Executor - Task executor for Tokio 0.2 runtime.