Loading Main.hs +7 −7 Original line number Diff line number Diff line Loading @@ -7,20 +7,20 @@ import qualified Data.Text.Lazy as L import Web.Scotty getClientIP1 :: ActionM (Maybe Text) getClientIP1 = header "HTTP_CLIENT_IP" getClientIP1 = header "CLIENT-IP" getClientIP2 :: ActionM (Maybe Text) getClientIP2 = fmap (maybe Nothing (Just . firstElement)) (header "HTTP_X_FORWARDED_FOR") where fmap (maybe Nothing (Just . firstElement)) (header "X-FORWARDED-FOR") where firstElement :: Text -> Text firstElement = head . L.splitOn "," getClientIP3 :: ActionM (Maybe Text) getClientIP3 = foldl1 (liftA2 (<|>)) $ map header ["HTTP_X_FORWARDED" ,"HTTP_X_CLUSTER_CLIENT_IP" ,"HTTP_FORWARDED_FOR" ,"HTTP_FORWARDED" ,"REMOTE_ADDR"] getClientIP3 = foldl1 (liftA2 (<|>)) $ map header ["X-FORWARDED" ,"X-CLUSTER-CLIENT-IP" ,"FORWARDED-FOR" ,"FORWARDED" ,"REMOTE-ADDR"] getClientIP :: ActionM () getClientIP = do Loading get-client-ip.cabal +1 −1 Original line number Diff line number Diff line name: get-client-ip version: 0.1.0 version: 0.1.1 cabal-version: >= 1.8 build-type: Simple Loading Loading
Main.hs +7 −7 Original line number Diff line number Diff line Loading @@ -7,20 +7,20 @@ import qualified Data.Text.Lazy as L import Web.Scotty getClientIP1 :: ActionM (Maybe Text) getClientIP1 = header "HTTP_CLIENT_IP" getClientIP1 = header "CLIENT-IP" getClientIP2 :: ActionM (Maybe Text) getClientIP2 = fmap (maybe Nothing (Just . firstElement)) (header "HTTP_X_FORWARDED_FOR") where fmap (maybe Nothing (Just . firstElement)) (header "X-FORWARDED-FOR") where firstElement :: Text -> Text firstElement = head . L.splitOn "," getClientIP3 :: ActionM (Maybe Text) getClientIP3 = foldl1 (liftA2 (<|>)) $ map header ["HTTP_X_FORWARDED" ,"HTTP_X_CLUSTER_CLIENT_IP" ,"HTTP_FORWARDED_FOR" ,"HTTP_FORWARDED" ,"REMOTE_ADDR"] getClientIP3 = foldl1 (liftA2 (<|>)) $ map header ["X-FORWARDED" ,"X-CLUSTER-CLIENT-IP" ,"FORWARDED-FOR" ,"FORWARDED" ,"REMOTE-ADDR"] getClientIP :: ActionM () getClientIP = do Loading
get-client-ip.cabal +1 −1 Original line number Diff line number Diff line name: get-client-ip version: 0.1.0 version: 0.1.1 cabal-version: >= 1.8 build-type: Simple Loading