From 8ba1dfa7c74b46ae334562c701404825ec3c8069 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Wed, 24 Jul 2024 16:13:13 -0500 Subject: [PATCH] Make RPC port configurable --- app/Server.hs | 2 +- src/Zenith/RPC.hs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Server.hs b/app/Server.hs index 95e9458..05db7fe 100644 --- a/app/Server.hs +++ b/app/Server.hs @@ -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) diff --git a/src/Zenith/RPC.hs b/src/Zenith/RPC.hs index f2b4bf7..9e190e9 100644 --- a/src/Zenith/RPC.hs +++ b/src/Zenith/RPC.hs @@ -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 $