@Override public Response handle(Stage.Unmarshalling argument) { Response result = argument.invoke(); Request request = argument.getRequest(); if (request.getPhase() == Phase.VIEW) { if (result instanceof Response.Content) { final Collection<Chunk.Property<String>> bar = foo(request.getHandler().getMethod(), Collections.<Chunk.Property<String>>emptyList()); Response.Status status = (Response.Status)result; if ((bar.size() > 0)) { status = new Response.Content(status.getCode(), new StreamableDecorator(status.streamable()) { @Override protected void sendHeader(Stream consumer) { for (Chunk.Property<String> asset : bar) { consumer.provide(asset); } } }); result = status; } } } return result; } }
@Override public Response handle(Stage.Unmarshalling argument) { Response result = argument.invoke(); Request request = argument.getRequest(); if (request.getPhase() == Phase.VIEW) { if (result instanceof Response.Content) { final Collection<Chunk.Property<String>> bar = foo(request.getHandler().getMethod(), Collections.<Chunk.Property<String>>emptyList()); Response.Status status = (Response.Status)result; if ((bar.size() > 0)) { status = new Response.Content(status.getCode(), new StreamableDecorator(status.streamable()) { @Override protected void sendHeader(Stream consumer) { for (Chunk.Property<String> asset : bar) { consumer.provide(asset); } } }); result = status; } } } return result; } }
/** * Renders the template and returns a response with the specified status. * * @return the response */ public final Response.Content status(int status) throws UndeclaredIOException { StringBuilder sb = new StringBuilder(); PropertyMap properties = new PropertyMap(); doRender(properties, sb); ChunkBuffer buffer = new ChunkBuffer().append(Chunk.create(sb)).close(); return new Response.Content(status, properties, buffer); }
result = new Response.Content(status.getCode(), wrapper);
result = new Response.Content(status.getCode(), wrapper);
public static Content content(int code, Streamable content) { return new Content(code, content); }
public Content content(Streamable s) { return new Content(code, properties, s); }
public Content content(Streamable s) { return new Content(code, properties, s); }
public static Content content(int code, Streamable content) { return new Content(code, content); }
/** * Renders the template and returns a response with the specified status. * * @return the response */ public final Response.Content status(int status) throws UndeclaredIOException { StringBuilder sb = new StringBuilder(); PropertyMap properties = new PropertyMap(); doRender(properties, sb); ChunkBuffer buffer = new ChunkBuffer().append(Chunk.create(sb)).close(); return new Response.Content(status, properties, buffer); }