Search in sources :

Example 1 with OnResponseContent

use of io.gravitee.policy.api.annotations.OnResponseContent in project gravitee-gateway by gravitee-io.

the class OverrideResponseContentPolicy method onResponseContent.

@OnResponseContent
public ReadWriteStream onResponseContent(Request request) {
    return new BufferedReadWriteStream() {

        @Override
        public SimpleReadWriteStream<Buffer> write(Buffer content) {
            // We dot want to get the request content, skipping
            return this;
        }

        @Override
        public void end() {
            Buffer content = Buffer.buffer(STREAM_POLICY_CONTENT);
            // Write content
            super.write(content);
            // Mark the end of content
            super.end();
        }
    };
}
Also used : Buffer(io.gravitee.gateway.api.buffer.Buffer) BufferedReadWriteStream(io.gravitee.gateway.api.stream.BufferedReadWriteStream) OnResponseContent(io.gravitee.policy.api.annotations.OnResponseContent)

Aggregations

Buffer (io.gravitee.gateway.api.buffer.Buffer)1 BufferedReadWriteStream (io.gravitee.gateway.api.stream.BufferedReadWriteStream)1 OnResponseContent (io.gravitee.policy.api.annotations.OnResponseContent)1