test ip headers
This commit is contained in:
parent
40b67993e5
commit
00b9d408cd
1 changed files with 5 additions and 12 deletions
17
src/Main.hs
17
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue