io.vertx.httpproxy.interceptors.impl.BodyTransformerImpl Maven / Gradle / Ivy
package io.vertx.httpproxy.interceptors.impl;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.httpproxy.interceptors.BodyTransformer;
import java.util.Objects;
import java.util.function.Function;
public class BodyTransformerImpl implements BodyTransformer {
private final Function transformer;
@Override
public Buffer apply(Buffer buffer) {
return transformer.apply(buffer);
}
private BodyTransformerImpl(Function transformer) {
this.transformer = Objects.requireNonNull(transformer);
}
public static BodyTransformerImpl transformJsonObject(Function transformer) {
return new BodyTransformerImpl(buffer -> transformer.apply(buffer.toJsonObject()).toBuffer());
}
public static BodyTransformerImpl transformJsonArray(Function transformer) {
return new BodyTransformerImpl(buffer -> transformer.apply(buffer.toJsonArray()).toBuffer());
}
public static BodyTransformerImpl transformJson(Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy