test ip headers

This commit is contained in:
mtgmonkey 2025-06-06 19:11:43 -04:00
parent 40b67993e5
commit 00b9d408cd

View file

@ -55,18 +55,6 @@ boilerplateJs = H.toHtml ($(embedStringFile "./init.js") :: String)
-- MAIN -- MAIN
main :: IO () main :: IO ()
main = do 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 scotty port $ do
middleware $ gzip $ def { gzipFiles = GzipCompress } middleware $ gzip $ def { gzipFiles = GzipCompress }
@ -74,11 +62,16 @@ main = do
-- GET requests -- GET requests
get "/" $ do get "/" $ do
h <- header "HTTP_CLIENT_IP"
r <- header "REMOTE_ADDR"
let fromMaybe d x = case x of {Nothing -> d;Just v -> v}
shortCache shortCache
status ok200 status ok200
S.html $ index $ do S.html $ index $ do
compiledElmApp compiledElmApp
boilerplateJs boilerplateJs
H.toHtml $ fromMaybe "HTTP_CLIENT_IP: Nothing" h
H.toHtml $ fromMaybe "REMOTE_ADDR: Nothing" r
get "/favicon.ico/" $ do get "/favicon.ico/" $ do
shortCache shortCache