All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.networknt.limit.key.RemoteAddressKeyResolver Maven / Gradle / Ivy

Go to download

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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy