use of org.webpieces.router.impl.routeinvoker.NullWriter in project webpieces by deanhiller.
the class ENotFoundRouter method invokeNotFoundRoute.
public XFuture<StreamWriter> invokeNotFoundRoute(RequestContext ctx, ProxyStreamHandle handle, NotFoundException exc) {
Endpoint info = new Endpoint(svc);
RouteInfoForNotFound data = new RouteInfoForNotFound(exc);
InvokeInfo invokeInfo = new InvokeInfo(ctx, handle, RouteType.NOT_FOUND, loadedController, i18nBaseBundle);
return invoker.invokeNotFound(invokeInfo, info, data).thenApply(voidd -> new NullWriter());
}
use of org.webpieces.router.impl.routeinvoker.NullWriter in project webpieces by deanhiller.
the class RequestResponseStream method openStream.
@Override
public RouterStreamRef openStream(MethodMeta meta, ProxyStreamHandle handle) {
boolean endOfStream = meta.getCtx().getRequest().originalRequest.isEndOfStream();
if (endOfStream) {
// If there is no body, just invoke to process OR IN CASE of InternalError or NotFound, there is NO need
// to wait for the request body and we can respond early, which stops wasting CPU of reading in their body
meta.getCtx().getRequest().body = DataWrapperGeneratorFactory.EMPTY;
XFuture<StreamWriter> invokeSvc = invoker.invokeSvc(meta, i18nBundleName, service, processor, handle).thenApply(voidd -> new NullWriter());
return new RouterStreamRef("reqRespStreamProxy", invokeSvc, null);
}
// At this point, we don't have the end of the stream so return a request writer that calls invoke when complete
RequestStreamWriter2 writer = new RequestStreamWriter2(requestBodyParsers, meta, (newInfo) -> invoker.invokeSvc(newInfo, i18nBundleName, service, processor, handle));
XFuture<StreamWriter> w = XFuture.completedFuture(writer);
return new RouterStreamRef("requestRespStream", w, null);
}
use of org.webpieces.router.impl.routeinvoker.NullWriter in project webpieces by deanhiller.
the class DevRouteInvoker method invokeHtmlController.
@Override
public RouterStreamRef invokeHtmlController(InvokeInfo invokeInfo, StreamService dynamicInfo, RouteData data) {
// special case for if stuff didn't compile and we flag it
Throwable exc = (Throwable) invokeInfo.getRequestCtx().getRequest().requestState.get(ERROR_KEY);
if (exc != null) {
log.error("Could not compile your code", exc);
RouteInfoForInternalError error = new RouteInfoForInternalError(exc);
XFuture<Void> future = invokeDevelopmentErrorPage(invokeInfo, error);
XFuture<StreamWriter> writer = future.thenApply(voidd -> new NullWriter());
return new RouterStreamRef("notCompileError", writer, null);
}
if (invokeInfo.getRequestCtx().getRequest().queryParams.containsKey(DevelopmentController.INTERNAL_ERROR_KEY)) {
// need to simulate the error to show production page
throw new SimulateInternalError();
}
// }
return super.invokeHtmlController(invokeInfo, dynamicInfo, data);
}
Aggregations