servant-jsonrpc-1.0.1: JSON-RPC messages and endpoints

Safe HaskellNone
LanguageHaskell2010

Servant.JsonRpc

Contents

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 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

JSON-RPC messages

data Request p Source #

Client messages

Constructors

Request 

Fields

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

Defined in Servant.JsonRpc

Methods

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

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

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 #

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

Defined in Servant.JsonRpc

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

Defined in Servant.JsonRpc

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
(Eq r, Eq e) => Eq (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

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

Defined in Servant.JsonRpc

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

Defined in Servant.JsonRpc

data JsonRpcErr e Source #

Constructors

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

Defined in Servant.JsonRpc

Methods

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

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

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

Defined in Servant.JsonRpc

Standard error codes

Type rewriting