use of com.webpieces.http2.api.streaming.ResponseStreamHandle in project webpieces by deanhiller.
the class JsonController method myStream.
// Method signature cannot have RequestContext since in microservices, we implement an api as the server
// AND a client implements the same api AND client does not have a RequestContext!!
@Override
public StreamRef myStream(ResponseStreamHandle handle2) {
RouterStreamHandle handle = (RouterStreamHandle) handle2;
RequestContext requestCtx = Current.getContext();
Http2Response response = handle.createBaseResponse(requestCtx.getRequest().originalRequest, "text/plain", 200, "Ok");
response.setEndOfStream(false);
XFuture<StreamWriter> responseWriter = handle.process(response);
return new RequestStreamEchoWriter(requestCtx, handle, responseWriter);
}
Aggregations