com.networknt.limit.key.RemoteAddressKeyResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rate-limit Show documentation
Show all versions of rate-limit Show documentation
A handler that does rate limit in order to prevent attacks for public facing services.
The newest version!
package com.networknt.limit.key;
import io.undertow.server.HttpServerExchange;
import java.net.InetSocketAddress;
/**
* When address is used as the key, we can get the IP address from the header of the request. If there
* is no proxy before our service and gateway, we can use the remote address for the purpose.
*
* @author Steve Hu
*/
public class RemoteAddressKeyResolver implements KeyResolver {
@Override
public String resolve(HttpServerExchange exchange) {
InetSocketAddress address = exchange.getSourceAddress();
return address.getHostString();
}
}