@Override
public void handle(Context context) throws Exception {
final Registry commandRegistry = context.join(registry);
final RegistryBuilder registryBuilder = Registries.registry();
Receiver receiver = new RatpackReceiver(chain -> new DelegatingCommandDelegate(registryBuilder, commandRegistry) {
@Override
public void clearRegistry() {
registryReference.set(null);
}
});
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
receiver.execute(context.getRequest().getBody().getInputStream(), outputStream);
if (registryBuilder.size() > 0) {
Registry newRegistry = registryBuilder.build();
registryReference.set(newRegistry);
}