Extension Point: HTTP Request Tag Set Populator
Basics
Parameter | Value |
---|---|
Extension Point Key | HTTP_TAG_SET_POPULATOR |
Extension Point Name | HTTP Request Tag Set Populator |
Extension Interface | HttpRequestTagSetPopulator |
Supports Multiple Extensions? | Yes |
Selector Type | Store |
Available Since | 1.0.0 |
Use Cases
Extensions implementing this Extension Point have access to the HTTP servlet request and can use that information to populate fields in the Tagging Framework. The values in the tagging framework can then be used for promotion and price list assignment conditions.
Methods
collectTagValues
The collectTagValues
method is invoked at the beginning of each Cortex API request. It can use data from the context, or make calls to external services to retrieve data that needs to be populated in the Tag Set.
Extension Sample
@Extension
@XPFAssignment(extensionPoint = XPFExtensionPointEnum.HTTP_TAG_SET_POPULATOR, priority = 100)
public class IPHttpRequestPopulator extends XPFExtensionPointImpl implements HttpRequestTagSetPopulator {
private static final String IP_ADDRESS = "ip-address";
private static final String X_FORWARDED_FOR = "X-FORWARDED-FOR";
@Override
public Map<String, String> collectTagValues(final XPFHttpTagSetContext httpTagSetContext) {
String ipAddress = httpTagSetContext.getHttpRequest().getHeader(X_FORWARDED_FOR);
if (StringUtils.isBlank(ipAddress)) {
ipAddress = httpTagSetContext.getHttpRequest().getRemoteAddr();
}
return Collections.singletonMap(IP_ADDRESS, ipAddress);
}
}