Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Network.JsonRpc.Types
Description
Work with JSON-RPC protocol
Synopsis
- data RawJsonRpc api
- data JsonRpc (method :: Symbol) p e r
- data JsonRpcNotification (method :: Symbol) p
- data JsonRpcContentType
- data Request p = Request {}
- data JsonRpcErr e = JsonRpcErr {}
- data JsonRpcResponse e r
- data UnusedRequestParams = UnusedRequestParams
- mkJsonRpcParseErr :: Maybe e -> JsonRpcErr e
- mkJsonRpcInvalidRequestErr :: Maybe e -> JsonRpcErr e
- mkJsonRpcMethodNotFoundErr :: Maybe e -> JsonRpcErr e
- mkJsonRpcInvalidParamsErr :: Maybe e -> JsonRpcErr e
- mkJsonRpcInternalErr :: Maybe e -> JsonRpcErr e
- type family JsonRpcEndpoint a where ...
API specification types
data RawJsonRpc api #
A JSON RPC server handles any number of methods.
Instances
HasClient m api => HasClient m (RawJsonRpc api) | The |
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 | |
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) | |
Defined in Network.JsonRpc.Client.Types type Client m (RawJsonRpc api) = Client m api | |
type ServerT (RawJsonRpc api :: Type) m | |
Defined in Network.JsonRpc.Server.Types |
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 methodp
: theparams
field type in the JSON-RPC requeste
: the error type for theresult
field in the JSON-RPC responser
: the value type of theresult
field in the JSON-RPC response
Instances
(RunClient m, KnownSymbol method, ToJSON p, FromJSON e, FromJSON r) => HasClient m (JsonRpc method p e r) | |
Defined in Network.JsonRpc.Client.Types Associated Types type Client m (JsonRpc method p e r) | |
(KnownSymbol method, FromJSON p, ToJSON e, ToJSON r) => RouteJsonRpc (JsonRpc method p e r) # | |
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) | |
Defined in Network.JsonRpc.Client.Types | |
type RpcHandler (JsonRpc method p e r) m # | |
Defined in Network.JsonRpc.Server.Types |
data JsonRpcNotification (method :: Symbol) p #
JSON-RPC endpoints which do not respond
Instances
(RunClient m, KnownSymbol method, ToJSON p) => HasClient m (JsonRpcNotification method p) | |
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) # | |
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) | |
Defined in Network.JsonRpc.Client.Types type Client m (JsonRpcNotification method p) = p -> m NoContent | |
type RpcHandler (JsonRpcNotification method p) m # | |
Defined in Network.JsonRpc.Server.Types |
data JsonRpcContentType #
The JSON-RPC content type.
Instances
Accept JsonRpcContentType # | |
Defined in Network.JsonRpc.Types Methods contentType :: Proxy JsonRpcContentType -> MediaType contentTypes :: Proxy JsonRpcContentType -> NonEmpty MediaType | |
ToJSON a => MimeRender JsonRpcContentType a # | |
Defined in Network.JsonRpc.Types Methods mimeRender :: Proxy JsonRpcContentType -> a -> ByteString | |
FromJSON a => MimeUnrender JsonRpcContentType a # | |
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) | |
Defined in Network.JsonRpc.Server.Types Methods handleAcceptH :: Proxy '[JsonRpcContentType] -> AcceptHeader -> MaybeContent a -> Maybe (ByteString, ByteString) |
JSON-RPC messages
Client messages
Constructors
Request | |
Instances
FromJSON p => FromJSON (Request p) # | |
Defined in Network.JsonRpc.Types | |
ToJSON p => ToJSON (Request p) # | |
Defined in Network.JsonRpc.Types Methods toEncoding :: Request p -> Encoding toJSONList :: [Request p] -> Value toEncodingList :: [Request p] -> Encoding | |
Show p => Show (Request p) # | |
Eq p => Eq (Request p) # | |
data JsonRpcErr e #
Constructors
JsonRpcErr | |
Instances
Show e => Show (JsonRpcErr e) # | |
Defined in Network.JsonRpc.Types | |
Eq e => Eq (JsonRpcErr e) # | |
Defined in Network.JsonRpc.Types Methods (==) :: JsonRpcErr e -> JsonRpcErr e -> Bool Source # (/=) :: JsonRpcErr e -> JsonRpcErr e -> Bool Source # |
data JsonRpcResponse e r #
Server Ack
message
Instances
(FromJSON e, FromJSON r) => FromJSON (JsonRpcResponse e r) # | |
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) # | |
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) # | |
Defined in Network.JsonRpc.Types | |
(Eq r, Eq e) => Eq (JsonRpcResponse e r) # | |
Defined in Network.JsonRpc.Types Methods (==) :: JsonRpcResponse e r -> JsonRpcResponse e r -> Bool Source # (/=) :: JsonRpcResponse e r -> JsonRpcResponse e r -> Bool Source # |
data UnusedRequestParams #
Constructors
UnusedRequestParams |
Instances
FromJSON UnusedRequestParams # | |
Defined in Network.JsonRpc.Types Methods parseJSON :: Value -> Parser UnusedRequestParams parseJSONList :: Value -> Parser [UnusedRequestParams] | |
ToJSON UnusedRequestParams # | |
Defined in Network.JsonRpc.Types Methods toJSON :: UnusedRequestParams -> Value toEncoding :: UnusedRequestParams -> Encoding toJSONList :: [UnusedRequestParams] -> Value toEncodingList :: [UnusedRequestParams] -> Encoding |
Smart constructors for standard JSON-RPC errors
mkJsonRpcParseErr :: Maybe e -> JsonRpcErr e #
JSON-RPC error codes based on JSONRPC Spec
mkJsonRpcInvalidRequestErr :: Maybe e -> JsonRpcErr e #
mkJsonRpcMethodNotFoundErr :: Maybe e -> JsonRpcErr e #
mkJsonRpcInvalidParamsErr :: Maybe e -> JsonRpcErr e #
mkJsonRpcInternalErr :: Maybe e -> JsonRpcErr e #
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 |