Get Request from happstack-lite API
-
22-06-2021 - |
문제
How would I go about getting the Request data from the happstack-lite API? I'm trying to get the client's IP address. From what I can tell it's in Request::rqPeer, and I get confused trying to dive into the monadic-layers of the happstack API.
해결책
You can use askRq
in any ServerMonad to get at the Request, which you could pattern match on with record syntax to get the client hostname:
do Request {rqPeer = (host,_)} <- askRq
ok $ "Your IP: " ++ host
제휴하지 않습니다 StackOverflow