Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Work with JSON-RPC protocol messages at both type and value level.
type Mul = JsonRpc "mul" (Int, Int) String Int req :: Request (Int, Int) req = Request "mul" (3, 5) (Just 0) rsp :: JsonRpcResponse String Int rsp = Result 0 15
Synopsis
- data RawJsonRpc ctype api
- data JsonRpc (method :: Symbol) p e r
- data JsonRpcNotification (method :: Symbol) p
- data JSONRPC
- data Request p = Request {}
- data JsonRpcResponse e r
- data JsonRpcErr e = JsonRpcErr {}
- parseErrorCode :: Int
- invalidRequestCode :: Int
- methodNotFoundCode :: Int
- invalidParamsCode :: Int
- internalErrorCode :: Int
- type family JsonRpcEndpoint ctype a where ...
API specification types
data RawJsonRpc ctype api Source #
A JSON RPC server handles any number of methods. Represent this at the type level using this type.
data JsonRpcNotification (method :: Symbol) p Source #
JSON-RPC endpoints which do not respond
The JSON-RPC content type
Instances
Accept JSONRPC Source # | |
Defined in Servant.JsonRpc | |
ToJSON a => MimeRender JSONRPC a Source # | |
Defined in Servant.JsonRpc mimeRender :: Proxy JSONRPC -> a -> ByteString # | |
FromJSON a => MimeUnrender JSONRPC a Source # | |
Defined in Servant.JsonRpc mimeUnrender :: Proxy JSONRPC -> ByteString -> Either String a # mimeUnrenderWithType :: Proxy JSONRPC -> MediaType -> ByteString -> Either String a # |
JSON-RPC messages
Client messages
data JsonRpcResponse e r Source #
Server messages. An Ack
is a message which refers to a Request
but
both its "errors" and "result" keys are null
Instances
(FromJSON e, FromJSON r) => FromJSON (JsonRpcResponse e r) Source # | |
Defined in Servant.JsonRpc parseJSON :: Value -> Parser (JsonRpcResponse e r) # parseJSONList :: Value -> Parser [JsonRpcResponse e r] # omittedField :: Maybe (JsonRpcResponse e r) # | |
(ToJSON e, ToJSON r) => ToJSON (JsonRpcResponse e r) Source # | |
Defined in Servant.JsonRpc toJSON :: JsonRpcResponse e r -> Value # toEncoding :: JsonRpcResponse e r -> Encoding # toJSONList :: [JsonRpcResponse e r] -> Value # toEncodingList :: [JsonRpcResponse e r] -> Encoding # omitField :: JsonRpcResponse e r -> Bool # | |
(Show r, Show e) => Show (JsonRpcResponse e r) Source # | |
Defined in Servant.JsonRpc showsPrec :: Int -> JsonRpcResponse e r -> ShowS # show :: JsonRpcResponse e r -> String # showList :: [JsonRpcResponse e r] -> ShowS # | |
(Eq r, Eq e) => Eq (JsonRpcResponse e r) Source # | |
Defined in Servant.JsonRpc (==) :: JsonRpcResponse e r -> JsonRpcResponse e r -> Bool # (/=) :: JsonRpcResponse e r -> JsonRpcResponse e r -> Bool # |
data JsonRpcErr e Source #
Instances
Show e => Show (JsonRpcErr e) Source # | |
Defined in Servant.JsonRpc showsPrec :: Int -> JsonRpcErr e -> ShowS # show :: JsonRpcErr e -> String # showList :: [JsonRpcErr e] -> ShowS # | |
Eq e => Eq (JsonRpcErr e) Source # | |
Defined in Servant.JsonRpc (==) :: JsonRpcErr e -> JsonRpcErr e -> Bool # (/=) :: JsonRpcErr e -> JsonRpcErr e -> Bool # |
Standard error codes
parseErrorCode :: Int Source #
Type rewriting
type family JsonRpcEndpoint ctype a where ... Source #
JsonRpcEndpoint ctype (JsonRpc m p e r) = ReqBody '[ctype] (Request p) :> Post '[ctype] (JsonRpcResponse e r) | |
JsonRpcEndpoint ctype (JsonRpcNotification m p) = ReqBody '[ctype] (Request p) :> Post '[ctype] NoContent |