marconi-core-json-rpc-1.2.0.0: Utilities for wrapping the query interface of Marconi indexers in a JSON-RPC HTTP server.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.JsonRpc.Types

Description

Work with JSON-RPC protocol

Synopsis

API specification types

data RawJsonRpc api #

A JSON RPC server handles any number of methods.

Instances

Instances details
HasClient m api => HasClient m (RawJsonRpc api)

The RawJsonRpc is transparent to clients

Instance details

Defined in Network.JsonRpc.Client.Types

Associated Types

type Client m (RawJsonRpc api)

Methods

clientWithRoute :: Proxy m -> Proxy (RawJsonRpc api) -> Request -> Client m (RawJsonRpc api)

hoistClientMonad :: Proxy m -> Proxy (RawJsonRpc api) -> (forall x. mon x -> mon' x) -> Client mon (RawJsonRpc api) -> Client mon' (RawJsonRpc api)

(RouteJsonRpc api, HasContextEntry (context .++ DefaultErrorFormatters) ErrorFormatters) => HasServer (RawJsonRpc api :: Type) context 
Instance details

Defined in Network.JsonRpc.Server.Types

Associated Types

type ServerT (RawJsonRpc api) m

Methods

route :: Proxy (RawJsonRpc api) -> Context context -> Delayed env (Server (RawJsonRpc api)) -> Router env

hoistServerWithContext :: Proxy (RawJsonRpc api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (RawJsonRpc api) m -> ServerT (RawJsonRpc api) n

type Client m (RawJsonRpc api) 
Instance details

Defined in Network.JsonRpc.Client.Types

type Client m (RawJsonRpc api) = Client m api
type ServerT (RawJsonRpc api :: Type) m 
Instance details

Defined in Network.JsonRpc.Server.Types

type ServerT (RawJsonRpc api :: Type) m = RpcHandler api m

data JsonRpc (method :: Symbol) p e r #

JSON-RPC endpoint which respond with a result given a query.

The type has the following type parameters:

  • method: the name of the JSON-RPC method
  • p: the params field type in the JSON-RPC request
  • e: the error type for the result field in the JSON-RPC response
  • r: the value type of the result field in the JSON-RPC response

Instances

Instances details
(RunClient m, KnownSymbol method, ToJSON p, FromJSON e, FromJSON r) => HasClient m (JsonRpc method p e r) 
Instance details

Defined in Network.JsonRpc.Client.Types

Associated Types

type Client m (JsonRpc method p e r)

Methods

clientWithRoute :: Proxy m -> Proxy (JsonRpc method p e r) -> Request -> Client m (JsonRpc method p e r)

hoistClientMonad :: Proxy m -> Proxy (JsonRpc method p e r) -> (forall x. mon x -> mon' x) -> Client mon (JsonRpc method p e r) -> Client mon' (JsonRpc method p e r)

(KnownSymbol method, FromJSON p, ToJSON e, ToJSON r) => RouteJsonRpc (JsonRpc method p e r) # 
Instance details

Defined in Network.JsonRpc.Server.Types

Associated Types

type RpcHandler (JsonRpc method p e r) m #

Methods

jsonRpcRouter :: Monad m => Proxy (JsonRpc method p e r) -> Proxy m -> RpcHandler (JsonRpc method p e r) m -> Map String (Value -> m (MaybeContent (Either (JsonRpcErr Value) Value))) #

hoistRpcRouter :: Proxy (JsonRpc method p e r) -> (forall x. m x -> n x) -> RpcHandler (JsonRpc method p e r) m -> RpcHandler (JsonRpc method p e r) n #

type Client m (JsonRpc method p e r) 
Instance details

Defined in Network.JsonRpc.Client.Types

type Client m (JsonRpc method p e r) = p -> m (JsonRpcResponse e r)
type RpcHandler (JsonRpc method p e r) m # 
Instance details

Defined in Network.JsonRpc.Server.Types

type RpcHandler (JsonRpc method p e r) m = p -> m (Either (JsonRpcErr e) r)

data JsonRpcNotification (method :: Symbol) p #

JSON-RPC endpoints which do not respond

Instances

Instances details
(RunClient m, KnownSymbol method, ToJSON p) => HasClient m (JsonRpcNotification method p) 
Instance details

Defined in Network.JsonRpc.Client.Types

Associated Types

type Client m (JsonRpcNotification method p)

Methods

clientWithRoute :: Proxy m -> Proxy (JsonRpcNotification method p) -> Request -> Client m (JsonRpcNotification method p)

hoistClientMonad :: Proxy m -> Proxy (JsonRpcNotification method p) -> (forall x. mon x -> mon' x) -> Client mon (JsonRpcNotification method p) -> Client mon' (JsonRpcNotification method p)

(KnownSymbol method, FromJSON p) => RouteJsonRpc (JsonRpcNotification method p) # 
Instance details

Defined in Network.JsonRpc.Server.Types

Associated Types

type RpcHandler (JsonRpcNotification method p) m #

Methods

jsonRpcRouter :: Monad m => Proxy (JsonRpcNotification method p) -> Proxy m -> RpcHandler (JsonRpcNotification method p) m -> Map String (Value -> m (MaybeContent (Either (JsonRpcErr Value) Value))) #

hoistRpcRouter :: Proxy (JsonRpcNotification method p) -> (forall x. m x -> n x) -> RpcHandler (JsonRpcNotification method p) m -> RpcHandler (JsonRpcNotification method p) n #

type Client m (JsonRpcNotification method p) 
Instance details

Defined in Network.JsonRpc.Client.Types

type Client m (JsonRpcNotification method p) = p -> m NoContent
type RpcHandler (JsonRpcNotification method p) m # 
Instance details

Defined in Network.JsonRpc.Server.Types

type RpcHandler (JsonRpcNotification method p) m = p -> m NoContent

data JsonRpcContentType #

The JSON-RPC content type.

Instances

Instances details
Accept JsonRpcContentType # 
Instance details

Defined in Network.JsonRpc.Types

ToJSON a => MimeRender JsonRpcContentType a # 
Instance details

Defined in Network.JsonRpc.Types

Methods

mimeRender :: Proxy JsonRpcContentType -> a -> ByteString

FromJSON a => MimeUnrender JsonRpcContentType a # 
Instance details

Defined in Network.JsonRpc.Types

Methods

mimeUnrender :: Proxy JsonRpcContentType -> ByteString -> Either String a

mimeUnrenderWithType :: Proxy JsonRpcContentType -> MediaType -> ByteString -> Either String a

ToJSON a => AllCTRender '[JsonRpcContentType] (MaybeContent a) 
Instance details

Defined in Network.JsonRpc.Server.Types

Methods

handleAcceptH :: Proxy '[JsonRpcContentType] -> AcceptHeader -> MaybeContent a -> Maybe (ByteString, ByteString)

JSON-RPC messages

data Request p #

Client messages

Constructors

Request 

Fields

Instances

Instances details
FromJSON p => FromJSON (Request p) # 
Instance details

Defined in Network.JsonRpc.Types

Methods

parseJSON :: Value -> Parser (Request p)

parseJSONList :: Value -> Parser [Request p]

ToJSON p => ToJSON (Request p) # 
Instance details

Defined in Network.JsonRpc.Types

Methods

toJSON :: Request p -> Value

toEncoding :: Request p -> Encoding

toJSONList :: [Request p] -> Value

toEncodingList :: [Request p] -> Encoding

Show p => Show (Request p) # 
Instance details

Defined in Network.JsonRpc.Types

Eq p => Eq (Request p) # 
Instance details

Defined in Network.JsonRpc.Types

Methods

(==) :: Request p -> Request p -> Bool Source #

(/=) :: Request p -> Request p -> Bool Source #

data JsonRpcErr e #

Constructors

JsonRpcErr 

Fields

Instances

Instances details
Show e => Show (JsonRpcErr e) # 
Instance details

Defined in Network.JsonRpc.Types

Eq e => Eq (JsonRpcErr e) # 
Instance details

Defined in Network.JsonRpc.Types

data JsonRpcResponse e r #

Server Ack message

Constructors

Result !Word64 !r 
Ack !Word64 
Errors !(Maybe Word64) !(JsonRpcErr e) 

Instances

Instances details
(FromJSON e, FromJSON r) => FromJSON (JsonRpcResponse e r) # 
Instance details

Defined in Network.JsonRpc.Types

Methods

parseJSON :: Value -> Parser (JsonRpcResponse e r)

parseJSONList :: Value -> Parser [JsonRpcResponse e r]

(ToJSON e, ToJSON r) => ToJSON (JsonRpcResponse e r) # 
Instance details

Defined in Network.JsonRpc.Types

Methods

toJSON :: JsonRpcResponse e r -> Value

toEncoding :: JsonRpcResponse e r -> Encoding

toJSONList :: [JsonRpcResponse e r] -> Value

toEncodingList :: [JsonRpcResponse e r] -> Encoding

(Show r, Show e) => Show (JsonRpcResponse e r) # 
Instance details

Defined in Network.JsonRpc.Types

(Eq r, Eq e) => Eq (JsonRpcResponse e r) # 
Instance details

Defined in Network.JsonRpc.Types

data UnusedRequestParams #

Constructors

UnusedRequestParams 

Instances

Instances details
FromJSON UnusedRequestParams # 
Instance details

Defined in Network.JsonRpc.Types

Methods

parseJSON :: Value -> Parser UnusedRequestParams

parseJSONList :: Value -> Parser [UnusedRequestParams]

ToJSON UnusedRequestParams # 
Instance details

Defined in Network.JsonRpc.Types

Smart constructors for standard JSON-RPC errors

mkJsonRpcParseErr :: Maybe e -> JsonRpcErr e #

JSON-RPC error codes based on JSONRPC Spec

Type rewriting

type family JsonRpcEndpoint a where ... #

JSON-RPC

Equations

JsonRpcEndpoint (JsonRpc m p e r) = ReqBody '[JsonRpcContentType] (Request p) :> Post '[JsonRpcContentType] (JsonRpcResponse e r) 
JsonRpcEndpoint (JsonRpcNotification m p) = ReqBody '[JsonRpcContentType] (Request p) :> Post '[JsonRpcContentType] NoContent