io.continual.flowcontrol.endpoints.ConfigFetch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of continualFlowControl Show documentation
Show all versions of continualFlowControl Show documentation
Continual's flow control system for event processing.
package io.continual.flowcontrol.endpoints;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import io.continual.flowcontrol.controlapi.ConfigTransferService;
import io.continual.flowcontrol.controlapi.ConfigTransferService.ServiceException;
import io.continual.http.service.framework.context.CHttpRequestContext;
import io.continual.http.service.framework.context.CHttpResponse;
import io.continual.iam.identity.Identity;
import io.continual.restHttp.ApiContextHelper;
import io.continual.util.data.StreamTools;
import io.continual.util.standards.MimeTypes;
import io.continual.util.standards.HttpStatusCodes;
public class ConfigFetch extends ApiContextHelper
{
public ConfigFetch ( ConfigTransferService configTransfer )
{
fConfigTransfer = configTransfer;
}
public void getConfig ( CHttpRequestContext context, String id ) throws IOException, ServiceException
{
try ( final InputStream is = fConfigTransfer.fetch ( id ) )
{
if ( is == null )
{
sendStatusCodeAndMessage ( context, HttpStatusCodes.k404_notFound, "Unknown configuration key." );
return;
}
final CHttpResponse resp = context.response ();
resp.setStatus ( HttpStatusCodes.k200_ok );
final OutputStream os = resp.getStreamForBinaryResponse ( MimeTypes.kAppGenericBinary );
StreamTools.copyStream ( is, os );
os.close ();
}
}
private final ConfigTransferService fConfigTransfer;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy