myHttpServer :: HTTPServerLiveConf -> IO ()
myHttpServer v = do
  void $ forkIO $ runServer "127.0.0.1"
  void $ forkIO $ runServer "::1"
  where
    runServer host =
      runSettings (setHost host $ setPort 5002 defaultSettings) app
    app req respond = do
      resp <- readIORef v
      let host =
            takeWhile (/= ':') $
            B.unpack $ fromJust $ lookup "Host" $ requestHeaders req
          path = B.unpack $ rawPathInfo req
      case lookup (host, path) resp of
        Nothing -> error $ show (host, path) ++ " not found in " ++ show resp
        Just r -> do
          putStrLn $
            "[HTTP-Server] Responding to request: " ++ show (host, path)
          respond $ responseLBS status200 [] (L.pack r)
myHttpServer :: HTTPServerLiveConf -> IO ()
myHttpServer v = do
  void $ forkIO $ runServer "127.0.0.1"
  void $ forkIO $ runServer "::1"
  where
    runServer host =
      runSettings (setHost host $ setPort 5002 defaultSettings) app
    app req respond = do
      resp <- readIORef v
      let host =
            takeWhile (/= ':') $
            B.unpack $ fromJust $ lookup "Host" $ requestHeaders req
          path = B.unpack $ rawPathInfo req
      case lookup (host, path) resp of
        Nothing -> error $ show (host, path) ++ " not found in " ++ show resp
        Just r -> do
          putStrLn $
            "[HTTP-Server] Responding to request: " ++ show (host, path)
          respond $ responseLBS status200 [] (L.pack r)
myHttpServer v = do
  void $ forkIO $ runServer "127.0.0.1"
  void $ forkIO $ runServer "::1"
  where
    runServer host =
      runSettings (setHost host $ setPort 5002 defaultSettings) app
    app req respond = do
      resp <- readIORef v
      let host =
            takeWhile (/= ':') $
            B.unpack $ fromJust $ lookup "Host" $ requestHeaders req
          path = B.unpack $ rawPathInfo req
      case lookup (host, path) resp of
        Nothing -> error $ show (host, path) ++ " not found in " ++ show resp
        Just r -> do
          putStrLn $
            "[HTTP-Server] Responding to request: " ++ show (host, path)
          respond $ responseLBS status200 [] (L.pack r)