All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.swisspush.gateleen.packing.PackingHandler Maven / Gradle / Ivy

The newest version!
package org.swisspush.gateleen.packing;

import io.vertx.core.Handler;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpServerRequest;

/**
 * Extract requests from a packing request and forward them to a handler.
 *
 * @author https://github.com/lbovet [Laurent Bovet]
 */
public class PackingHandler implements Handler {

    private HttpServerRequest request;
    private Handler nextHandler;

    public static final String PACK_HEADER = "X-Pack-Size";

    public static boolean isPacked(HttpServerRequest request) {
        return request.headers().get(PACK_HEADER) != null;
    }

    /**
     * @param request request
     * @param nextHandler the handle to forward the unpacked
     */
    public PackingHandler(HttpServerRequest request, Handler nextHandler) {
        super();
        this.request = request;
        this.nextHandler = nextHandler;
    }

    @Override
    public void handle(Buffer event) {
        request.bodyHandler(event1 -> nextHandler.handle(event1));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy