如何在http请求中了解客户端域

I am making an API for an app (using golang) that will be consumed by different clients. I would know if there is any way to know the domain of the client that is doing the request.

Thank you very much.

The http.Request contains a RemoteAddr field which should provide the information you seek.

you can get it in RemoteAddr string field in http.Request

RemoteAddr allows HTTP servers and other software to record the network address that sent the request, usually for logging. This field is not filled in by ReadRequest and has no defined format. The HTTP server in this package sets RemoteAddr to an "IP:port" address before invoking a handler.

This field is ignored by the HTTP client