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

org.mockserver.codec.MockServerHttpToNettyHttpRequestEncoder Maven / Gradle / Ivy

There is a newer version: 5.15.0
Show newest version
package org.mockserver.codec;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
import org.mockserver.mappers.MockServerHttpRequestToFullHttpRequest;
import org.mockserver.logging.MockServerLogger;
import org.mockserver.model.HttpRequest;

import java.util.List;

/**
 * @author jamesdbloom
 */
public class MockServerHttpToNettyHttpRequestEncoder extends MessageToMessageEncoder {

    private final MockServerHttpRequestToFullHttpRequest mockServerHttpRequestToFullHttpRequest;

    MockServerHttpToNettyHttpRequestEncoder(MockServerLogger mockServerLogger) {
        mockServerHttpRequestToFullHttpRequest = new MockServerHttpRequestToFullHttpRequest(mockServerLogger);
    }

    @Override
    protected void encode(ChannelHandlerContext ctx, HttpRequest httpRequest, List out) {
        out.add(mockServerHttpRequestToFullHttpRequest.mapMockServerRequestToNettyRequest(httpRequest));
    }

}