From 00b9d408cd9b6d8c0ed1b2f4721514c5a0f9975d Mon Sep 17 00:00:00 2001 From: mtgmonkey Date: Fri, 6 Jun 2025 19:11:43 -0400 Subject: [PATCH] test ip headers --- src/Main.hs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 9f06228..fd5cbb4 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -55,18 +55,6 @@ boilerplateJs = H.toHtml ($(embedStringFile "./init.js") :: String) -- MAIN main :: IO () main = do - - compiledElmAppOrExc <- E.try $ readFile $ assetsFolder ++ compiledElmAppFile :: IO (Either E.IOException String) - let compiledElmApp' = case compiledElmAppOrExc of - Left e -> serverErrorReadFile e - Right contents -> H.toHtml $ contents - - boilerplateJsOrExc <- E.try $ readFile $ assetsFolder ++ boilerplateJsFile :: IO (Either E.IOException String) - let boilerplateJs' = case boilerplateJsOrExc of - Left e -> serverErrorReadFile e - Right contents -> H.toHtml $ contents - - let anyRoute = regex "^.*$" scotty port $ do middleware $ gzip $ def { gzipFiles = GzipCompress } @@ -74,11 +62,16 @@ main = do -- GET requests get "/" $ do + h <- header "HTTP_CLIENT_IP" + r <- header "REMOTE_ADDR" + let fromMaybe d x = case x of {Nothing -> d;Just v -> v} shortCache status ok200 S.html $ index $ do compiledElmApp boilerplateJs + H.toHtml $ fromMaybe "HTTP_CLIENT_IP: Nothing" h + H.toHtml $ fromMaybe "REMOTE_ADDR: Nothing" r get "/favicon.ico/" $ do shortCache