Crate susydev_jsonrpc_http_server

Source
Expand description

jsonrpc http server.

use susydev_jsonrpc_core::*;
use susydev_jsonrpc_http_server::*;

fn main() {
	let mut io = IoHandler::new();
	io.add_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 susydev_jsonrpc_core;
pub use crate::server_utils::tokio;

Modules§

cors
CORS handling utility functions

Structs§

Host
Host type
Origin
Request Origin
Response
Simple server response structure
Rpc
RPC Handler bundled with metadata extractor.
Server
jsonrpc http server instance
ServerBuilder
Convenient JSON-RPC HTTP Server builder.
ServerHandler
jsonrpc http request handler.
SuspendableStream
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:

Enums§

AccessControlAllowOrigin
Origins allowed to access
AllowCors
CORS response headers
DomainsValidation
Specifies if domains should be validated.
RequestMiddlewareAction
Action undertaken by a middleware.
RestApi
REST -> RPC converter state.

Traits§

MetaExtractor
Extracts metadata from the HTTP request.
RequestMiddleware
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.