Pergunta

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.

Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top