use of com.ociweb.gl.api.GreenRuntime in project GreenLightning by oci-pronghorn.
the class OpenCloseTestServer method declareBehavior.
@Override
public void declareBehavior(GreenRuntime runtime) {
HTTPResponseService respClose = runtime.newCommandChannel().newHTTPResponseService();
runtime.addRestListener((r) -> {
HeaderWritable headers = (w) -> {
w.write(HTTPHeaderDefaults.CONNECTION, "close");
};
return respClose.publishHTTPResponse(r, headers, null, Writable.NO_OP);
}).includeRoutes(alwaysCloseRoute);
HTTPResponseService respOpen = runtime.newCommandChannel().newHTTPResponseService();
runtime.addRestListener((r) -> {
respOpen.publishHTTPResponse(r, 200);
return true;
}).includeRoutes(neverCloseRoute);
}
use of com.ociweb.gl.api.GreenRuntime in project GreenLightning by oci-pronghorn.
the class EchoExampleApp method declareBehavior.
@Override
public void declareBehavior(GreenRuntime runtime) {
HTTPResponseService resp = runtime.newCommandChannel().newHTTPResponseService();
runtime.addRestListener("restListener", (r) -> {
HeaderWritable headers = new HeaderWritable() {
@Override
public void write(HeaderWriter writer) {
writer.write(HTTPHeaderDefaults.DNT, "true");
writer.write(HTTPHeaderDefaults.STRICT_TRANSPORT_SECURITY, "hello");
}
};
Writable writable = new Writable() {
@Override
public void write(ChannelWriter writer) {
// no response
}
};
return resp.publishHTTPResponse(r, headers, null, writable);
}).includeAllRoutes();
}
Aggregations