Hi All,
Could anyone give pointers on how i can fetch the country code being passed from cloudflare which is in our response header within the JAVA model ?
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
There are 2 ways, i guess first way is relevant to your requirement
1. Getting Value from SlingModel to Sightly -
https://www.argildx.com/technology/sling-model-sightly-part/
- You need to process the logic from cloudfare to get the countrycode and provide back to sightly.
https://helpx.adobe.com/experience-manager/using/sling_model_adaptation.html
Example -
@Model(adaptables = {SlingHttpServletRequest.class, Resource.class}, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@SlingObject
private SlingHttpServletRequest request;
request.getHeader("HeaderKEY");
2. Passing the value through Sightly to SlingModel -
https://stackoverflow.com/questions/42324000/how-to-call-sling-model-method-with-input-parameter-aem
- If you want to pass the countrycode from sightly to slingModel
Thanks,
Kiran Parab
Hi Binoy,
Define your model with adaptables = { SlingHttpServletRequest.class }, then in your model body add
@Deleted Account
private SlingHttpServletRequest request;
Once you are inside your init method you can ask for the header value
request.getHeader("my-header"));
Regards,
Peter
Views
Replies
Total Likes
Hi,
There are 2 ways, i guess first way is relevant to your requirement
1. Getting Value from SlingModel to Sightly -
https://www.argildx.com/technology/sling-model-sightly-part/
- You need to process the logic from cloudfare to get the countrycode and provide back to sightly.
https://helpx.adobe.com/experience-manager/using/sling_model_adaptation.html
Example -
@Model(adaptables = {SlingHttpServletRequest.class, Resource.class}, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@SlingObject
private SlingHttpServletRequest request;
request.getHeader("HeaderKEY");
2. Passing the value through Sightly to SlingModel -
https://stackoverflow.com/questions/42324000/how-to-call-sling-model-method-with-input-parameter-aem
- If you want to pass the countrycode from sightly to slingModel
Thanks,
Kiran Parab
Hi @binoy9299,
You can refer the below link for this purpose https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-h...
this is just extension on @Peter_Puzanovs post.
Views
Likes
Replies
Views
Likes
Replies