module API.Federator where
import Data.Function
import GHC.Stack
import qualified Network.HTTP.Client as HTTP
import Testlib.Prelude
getMetrics ::
(HasCallStack, MakesValue domain) =>
domain ->
(ServiceMap -> HostPort) ->
App Response
getMetrics :: forall domain.
(HasCallStack, MakesValue domain) =>
domain -> (ServiceMap -> HostPort) -> App Response
getMetrics domain
domain ServiceMap -> HostPort
service = do
req <- domain -> (ServiceMap -> HostPort) -> String -> App Request
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> (ServiceMap -> HostPort) -> String -> App Request
rawBaseRequestF domain
domain ServiceMap -> HostPort
service String
"i/metrics"
submit "GET" req
rawBaseRequestF :: (HasCallStack, MakesValue domain) => domain -> (ServiceMap -> HostPort) -> String -> App HTTP.Request
rawBaseRequestF :: forall domain.
(HasCallStack, MakesValue domain) =>
domain -> (ServiceMap -> HostPort) -> String -> App Request
rawBaseRequestF domain
domain ServiceMap -> HostPort
getService String
path = do
domainV <- domain -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
objDomain domain
domain
serviceMap <- getServiceMap domainV
liftIO . HTTP.parseRequest $
let HostPort h p = getService serviceMap
in "http://" <> h <> ":" <> show p <> ("/" <> joinHttpPath (splitHttpPath path))