문제

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top