Make RPC port configurable

This commit is contained in:
Rene Vergara 2024-07-24 16:13:13 -05:00
parent cbcf7c9c8c
commit 8ba1dfa7c7
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
2 changed files with 5 additions and 5 deletions

View file

@ -19,5 +19,5 @@ main = do
nodePort <- require config "nodePort"
let myConfig = Config dbFilePath zebraHost zebraPort nodeUser nodePwd nodePort
let ctx = authenticate myConfig :. EmptyContext
run 8081 $
run nodePort $
serveWithContext (Proxy :: Proxy ZenithRPC) ctx (zenithServer myConfig)

View file

@ -25,9 +25,9 @@ import Zenith.Types
)
type ZenithRPC
= "status" :> Get '[ JSON] Value :<|> ReqBody '[ JSON] RpcCall :> Post
= "status" :> Get '[ JSON] Value :<|> BasicAuth "zenith-realm" Bool :> ReqBody
'[ JSON]
(RpcResponse Value)
RpcCall :> Post '[ JSON] (RpcResponse Value)
zenithServer :: Config -> Server ZenithRPC
zenithServer config = getinfo :<|> handleRPC
@ -39,8 +39,8 @@ zenithServer config = getinfo :<|> handleRPC
[ "version" .= ("0.7.0.0-beta" :: String)
, "network" .= ("testnet" :: String)
]
handleRPC :: RpcCall -> Handler (RpcResponse Value)
handleRPC req =
handleRPC :: Bool -> RpcCall -> Handler (RpcResponse Value)
handleRPC isAuth req =
case method req of
UnknownMethod ->
return $