Closed lpil closed 1 year ago
Currently, unless it's provided as a header, it is not accessible.
I think I'd have to make a custom Request type with that as a field on it (which might make sense, this isn't the first item like this to come up).
Does that make sense to you?
Other options could be to have a special body type or to add it as a header perhaps.
What other things like this are there?
Sorry I left this open for so long...
It seems like:
remote_ip
on the Conn
structcowboy_req:peer
method, so has it as a value on the request recordreq.socket.remoteAddress
req.ip
fieldHappy to peruse some more to more fully flesh this out. I do think since the exported functions to actually handle the req->resp in mist could be inferred, I could pretty easily make a new type that extends the gleam/http
one? If you don't like that idea, I am definitely open to others!
I think it may be nicer to put any additional data in the body field rather than as a wrapper around Request/Response as otherwise no functions that work with gleam_http will work with Mist without an adapter. Or alternatively it could be a second data structure passed alongside the request? I'm unsure what is the best design overall.
Sorry I left this open for so long...
Nonsense! No rush at all and I'm super grateful for this fab project of yours 💜
Hmm yeah, I see what you mean. I agree it would be weird to require some transformation to work with gleam/http
, but also overloading the req.body
also seems a little strange. I'll reference what else is included in some of these other implementations, and maybe it'll become clearer. To your latter suggestion, something like an additional ConnectionInfo
or similar might make sense? Some of the handlers are already passed the state, so it could be included as part of that / an additional argument. Will think on it!
This is supported now 🎉
Hello!
Is there a way to the the IP address of the requester?
Thanks, Louis