class ResponseEncodeHandler implements MiddlewareHandler {
    public static ResponseEncodeConfig config =
        (ResponseEncodeConfig)Config.getInstance().getJsonObjectConfig(ResponseEncodeConfig.CONFIG_NAME, ResponseEncodeConfig.class);

    static final String NO_ENCODING_HANDLER = "ERR10050";
    private final ContentEncodingRepository contentEncodingRepository;

    private volatile HttpHandler next;


    public ResponseEncodeHandler() {
        contentEncodingRepository = new ContentEncodingRepository();
        List<String> encoders = config.getEncoders();
        for(int i = 0; i < encoders.size(); i++) {
            String encoder = encoders.get(i);
            if(Constants.ENCODE_GZIP.equals(encoder)) {
                contentEncodingRepository.addEncodingHandler(encoder, new GzipEncodingProvider(), 100);
            } else if(Constants.ENCODE_DEFLATE.equals(encoder)) {
                contentEncodingRepository.addEncodingHandler(encoder, new DeflateEncodingProvider(), 10);
            } else {
                throw new RuntimeException("Invalid encoder " + encoder + " for ResponseEncodeHandler.");
            }
        }
    }

    @Override
    public HttpHandler getNext() {
        return next;
    }

    @Override
    public MiddlewareHandler setNext(HttpHandler next) {
        Handlers.handlerNotNull(next);
        this.next = next;
        return this;
    }

    @Override
    public boolean isEnabled() {
        return config.isEnabled();
    }

    @Override
    public void register() {
        ModuleRegistry.registerModule(ResponseEncodeConfig.CONFIG_NAME, ResponseEncodeHandler.class.getName(), Config.getNoneDecryptedInstance().getJsonMapConfigNoCache(ResponseEncodeConfig.CONFIG_NAME), null);
    }

    @Override
    public void handleRequest(HttpServerExchange exchange) throws Exception {<FILL_FUNCTION_BODY>}

    @Override
    public void reload() {
        config.reload();
        ModuleRegistry.registerModule(ResponseEncodeConfig.CONFIG_NAME, ResponseEncodeHandler.class.getName(), Config.getNoneDecryptedInstance().getJsonMapConfigNoCache(ResponseEncodeConfig.CONFIG_NAME), null);
        if(logger.isInfoEnabled()) logger.info("ResponseEncodeHandler is reloaded.");
    }
}

        AllowedContentEncodings encodings = contentEncodingRepository.getContentEncodings(exchange);
        if (encodings == null || !exchange.isResponseChannelAvailable()) {
            Handler.next(exchange, next);
        } else if (encodings.isNoEncodingsAllowed()) {
            setExchangeStatus(exchange, NO_ENCODING_HANDLER);
            return;
        } else {
            exchange.addResponseWrapper(encodings);
            exchange.putAttachment(AllowedContentEncodings.ATTACHMENT_KEY, encodings);
            Handler.next(exchange, next);
        }
    
<no_super_class>