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.Server.Types

Description

This module provides support for writing handlers for JSON-RPC endpoints

Synopsis

Documentation

data MaybeContent a #

The entire JSON RPC api is collapsed to a single endpoint. Therefore, we need a type that may or may not return content.

Constructors

SomeContent !a 
EmptyContent 

Instances

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

Defined in Network.JsonRpc.Server.Types

Methods

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

class RouteJsonRpc a where #

This internal class is how we accumulate a map of handlers for dispatch

Associated Types

type RpcHandler a (m :: Type -> Type) #

Methods

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

hoistRpcRouter :: Proxy a -> (forall x. m x -> n x) -> RpcHandler a m -> RpcHandler a n #

Instances

Instances details
(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 #

(RouteJsonRpc a, RouteJsonRpc b) => RouteJsonRpc (a :<|> b) # 
Instance details

Defined in Network.JsonRpc.Server.Types

Associated Types

type RpcHandler (a :<|> b) m #

Methods

jsonRpcRouter :: Monad m => Proxy (a :<|> b) -> Proxy m -> RpcHandler (a :<|> b) m -> Map String (Value -> m (MaybeContent (Either (JsonRpcErr Value) Value))) #

hoistRpcRouter :: Proxy (a :<|> b) -> (forall x. m x -> n x) -> RpcHandler (a :<|> b) m -> RpcHandler (a :<|> b) n #

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

generalizeResponse :: (ToJSON e, ToJSON r) => Either (JsonRpcErr e) r -> Either (JsonRpcErr Value) Value #

serveJsonRpc :: (Monad m, RouteJsonRpc a) => Proxy a -> Proxy m -> RpcHandler a m -> Request Value -> m MaybeJsonRpcResponse #

Collapse a to a single handler to handle RawJsonRpc

Orphan instances

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

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