servant-jsonrpc-1.2.0: JSON-RPC messages and endpoints
Safe HaskellSafe-Inferred
LanguageHaskell2010

Servant.JsonRpc

Description

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

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 JsonRpc (method :: Symbol) p e r Source #

JSON-RPC endpoints which respond with a result

data JsonRpcNotification (method :: Symbol) p Source #

JSON-RPC endpoints which do not respond

data JSONRPC Source #

The JSON-RPC content type

Instances

Instances details
Accept JSONRPC Source # 
Instance details

Defined in Servant.JsonRpc

ToJSON a => MimeRender JSONRPC a Source # 
Instance details

Defined in Servant.JsonRpc

Methods

mimeRender :: Proxy JSONRPC -> a -> ByteString #

FromJSON a => MimeUnrender JSONRPC a Source # 
Instance details

Defined in Servant.JsonRpc

JSON-RPC messages

data Request p Source #

Client messages

Constructors

Request 

Fields

Instances

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

Defined in Servant.JsonRpc

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

Defined in Servant.JsonRpc

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

Defined in Servant.JsonRpc

Methods

showsPrec :: Int -> Request p -> ShowS #

show :: Request p -> String #

showList :: [Request p] -> ShowS #

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

Defined in Servant.JsonRpc

Methods

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

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

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

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

Defined in Servant.JsonRpc

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

Defined in Servant.JsonRpc

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

Defined in Servant.JsonRpc

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

Defined in Servant.JsonRpc

data JsonRpcErr e Source #

Constructors

JsonRpcErr 

Instances

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

Defined in Servant.JsonRpc

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

Defined in Servant.JsonRpc

Methods

(==) :: JsonRpcErr e -> JsonRpcErr e -> Bool #

(/=) :: JsonRpcErr e -> JsonRpcErr e -> Bool #

Standard error codes

Type rewriting

type family JsonRpcEndpoint ctype a where ... Source #

Equations

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