use of com.ociweb.gl.api.Writable in project GreenLightning by oci-pronghorn.
the class JSONServerBehavior method restRequest.
@Override
public boolean restRequest(HTTPRequestReader request) {
int f = request.structured().readInt(flagsFieldId);
request.openPayloadData(reader -> {
jsonRequest.reset();
jsonRequest.readFromJSON(jsonReader, reader);
});
System.out.println("Server: " + f + " " + jsonRequest);
if (f == 42)
assertEquals(42, jsonRequest.getValue());
if (f == -6)
assertEquals(43, jsonRequest.getValue());
channel.publishHTTPResponse(request.getConnectionId(), request.getSequenceCode(), 200, false, HTTPContentTypeDefaults.JSON, new Writable() {
@Override
public void write(ChannelWriter writer) {
// System.err.println("pre "+writer.length());
response.writeToJSON(writer);
// System.err.println("post "+writer.length());
}
});
// runtime.shutdownRuntime();
return true;
}
Aggregations