class JsonRpc::HttpClient

Overview

Implements JSON-RPC over HTTP transport. Uses POST requests and doesn't support notifications to be received.

Authentication

To do authentication, configure the HTTP::Client you pass in as needed.

An example for HTTP Basic auth:

http_client = HTTP::Client.new("some.internal.server", 1234)
http_client.basic_auth("my-username", "the-password")

rpc_client = JsonRpc::HttpClient.new(http_client)
# rpc_client will now use basic authentication for each request!

Defined in:

json_rpc/http_client.cr

Constructors

Instance Method Summary

Instance methods inherited from class JsonRpc::Client

async_call : Bool async_call, async_call=(async_call : Bool) async_call=, call(result_type, method : String, params = nil) call, call?(result_type, method : String, params = nil) call?, close close, connection_lost : Signal_connection_lost connection_lost, fatal_local_error : Signal_fatal_local_error fatal_local_error, fatal_remote_error : Signal_fatal_remote_error fatal_remote_error, flood_messages : Int32 | Nil flood_messages, flood_messages=(flood_messages : Int32 | Nil) flood_messages=, flood_protection_triggered : Signal_flood_protection_triggered flood_protection_triggered, flood_time_span : Time::Span flood_time_span, flood_time_span=(flood_time_span : Time::Span) flood_time_span=, handler : Handler handler, handler=(handler : Handler) handler=, invoke_from_remote(request : Request, raw : String) : Nil invoke_from_remote, messages_received : UInt64 messages_received, messages_sent : UInt64 messages_sent, notification : Signal_notification notification, notify(method : String, params = nil) notify, notify_raw(message : String) notify_raw, recv_message(id) recv_message, remote_address : String remote_address, running? : Bool running?, send_message(id, message_data : String) send_message, send_response(response : Response) send_response

Constructor methods inherited from class JsonRpc::Client

new new

Constructor Detail

def self.new(http_client : HTTP::Client, endpoint : String = "/") #

[View source]

Instance Method Detail

def endpoint : String #

[View source]
def endpoint=(endpoint : String) #

[View source]
def http_client : HTTP::Client #

[View source]
def inspect(io) #

[View source]
def recv_message(id) #

Dummy implementation, this client doesn't use a persistant connection, and will never receive a remotely-initiated packet.


[View source]
def remote_address : String #
Description copied from class JsonRpc::Client

Returns the remote address for display/logging purposes


[View source]
def send_message(id, message_data) #

[View source]