Reputation: 193
The actual client who invoke the service is in the internal property "REMOTE_ADDRESS". But we can not retrieve it from ballerina http:Request . Is there a way we can get the remote IP of the client from http request in ballerina
ballerina version 0.97.1
Upvotes: 1
Views: 213
Reputation: 478
You cannot retrieve IP address from http request. Ballerina has Remote host/port in endpoint to construct the address. Please check following code snippet.
@http:ResourceConfig {
path:"/local",
methods:["GET"]
}
sample (endpoint caller, http:Request req) {
string remoteHost = caller.remote.host;
int remotePort = caller.remote.port;
}
Upvotes: 0