Extract PathParam From The URL

Viewed 53

I want to extract pathparam from url; This is my url below

www.url.com/api/customer/897979/agent/6758/platform/win

Here cutomer_id=897979 and agent_id=agent and platform_id=win

My Class extends AbstractFactoryFilter

 @Override
public GatewayFilter apply(Object config) {
    return (exchange, chain) -> {

        return chain.filter(exchange).then(Mono.fromRunnable(() -> {

        }));
    };
}

I tried using the below,But it return null

    RequestPath path = exchange.getRequest().getPath();

I also tried something like this

 private HashMap<String, String> getPathParameters(String uri, String strUrlTemplate) {

    UriTemplate template = new UriTemplate(strUrlTemplate);
    Map<String, String> parameters = new HashMap<>();
    Boolean value = template.match(uri, parameters);
    return new HashMap<>(parameters);

}

UPDATE :

I want to extract cutomer_id=897979 and agent_id=agent and platform_id=win

from the below url

www.url.com/api/customer/897979/agent/6758/platform/win

I am using AbstractFragemtFilter

public class FragmentFilter extends AbstractGatewayFilterFactory 
0 Answers
Related