Milestone 3: RPC server, ZIP-320 #104
2 changed files with 5 additions and 5 deletions
|
@ -19,5 +19,5 @@ main = do
|
||||||
nodePort <- require config "nodePort"
|
nodePort <- require config "nodePort"
|
||||||
let myConfig = Config dbFilePath zebraHost zebraPort nodeUser nodePwd nodePort
|
let myConfig = Config dbFilePath zebraHost zebraPort nodeUser nodePwd nodePort
|
||||||
let ctx = authenticate myConfig :. EmptyContext
|
let ctx = authenticate myConfig :. EmptyContext
|
||||||
run 8081 $
|
run nodePort $
|
||||||
serveWithContext (Proxy :: Proxy ZenithRPC) ctx (zenithServer myConfig)
|
serveWithContext (Proxy :: Proxy ZenithRPC) ctx (zenithServer myConfig)
|
||||||
|
|
|
@ -25,9 +25,9 @@ import Zenith.Types
|
||||||
)
|
)
|
||||||
|
|
||||||
type ZenithRPC
|
type ZenithRPC
|
||||||
= "status" :> Get '[ JSON] Value :<|> ReqBody '[ JSON] RpcCall :> Post
|
= "status" :> Get '[ JSON] Value :<|> BasicAuth "zenith-realm" Bool :> ReqBody
|
||||||
'[ JSON]
|
'[ JSON]
|
||||||
(RpcResponse Value)
|
RpcCall :> Post '[ JSON] (RpcResponse Value)
|
||||||
|
|
||||||
zenithServer :: Config -> Server ZenithRPC
|
zenithServer :: Config -> Server ZenithRPC
|
||||||
zenithServer config = getinfo :<|> handleRPC
|
zenithServer config = getinfo :<|> handleRPC
|
||||||
|
@ -39,8 +39,8 @@ zenithServer config = getinfo :<|> handleRPC
|
||||||
[ "version" .= ("0.7.0.0-beta" :: String)
|
[ "version" .= ("0.7.0.0-beta" :: String)
|
||||||
, "network" .= ("testnet" :: String)
|
, "network" .= ("testnet" :: String)
|
||||||
]
|
]
|
||||||
handleRPC :: RpcCall -> Handler (RpcResponse Value)
|
handleRPC :: Bool -> RpcCall -> Handler (RpcResponse Value)
|
||||||
handleRPC req =
|
handleRPC isAuth req =
|
||||||
case method req of
|
case method req of
|
||||||
UnknownMethod ->
|
UnknownMethod ->
|
||||||
return $
|
return $
|
||||||
|
|
Loading…
Reference in a new issue