I need to provide a Restful API in Sling, but for some data that isn't in the repo... This API will proxy to other external datastores.
Sling developers recommend creating a ResourceProvider. I've created this ResourceProvider implementation, however I'm getting a 403 when I request it:
@Component
@Service(value=ResourceProvider.class)
@Properties({
@Property(name = ResourceProvider.ROOTS, value = "things"),
@Property(name = ResourceProvider.OWNS_ROOTS, value = "true")
})
public class ImageResourceProvider implements ResourceProvider {
@Override
public Resource getResource(ResourceResolver resourceResolver, String path) {
Resource returnResource = new SyntheticResource(resourceResolver, path, "edlio/microservice/image");
returnResource.getValueMap().put("myProp" , "myValue");
return returnResource;
}
@Override
public Resource getResource(ResourceResolver resourceResolver, HttpServletRequest httpServletRequest, String path) {
return getResource(resourceResolver , path);
}
@Override
public Iterator<Resource> listChildren(Resource resource) {
return null;
}
When I go to /things, I get a 403. How can I control the authentication/authorization rules for this resource that doesn't exist?
Also, I can't use the ResourceProvider example code here because it uses the spi package which isn't inside of Sling 8... Sling 8 uses an older version of the sling api package.
I solved this myself and posted my answer here: Adobe CQ5 custom servlet path
Search for the answer from lance.dolan