Search in sources :

Example 1 with RouterStreamHandle

use of org.webpieces.router.api.RouterStreamHandle 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);
}
Also used : RouterStreamHandle(org.webpieces.router.api.RouterStreamHandle) Http2Response(com.webpieces.http2.api.dto.highlevel.Http2Response) StreamWriter(com.webpieces.http2.api.streaming.StreamWriter) RequestContext(org.webpieces.ctx.api.RequestContext)

Aggregations

Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)1 StreamWriter (com.webpieces.http2.api.streaming.StreamWriter)1 RequestContext (org.webpieces.ctx.api.RequestContext)1 RouterStreamHandle (org.webpieces.router.api.RouterStreamHandle)1