class SidecarRouterHandler extends RouterHandler implements MiddlewareHandler{
    private static final Logger logger = LoggerFactory.getLogger(SidecarRouterHandler.class);

    private volatile HttpHandler next;
    public static final String ROUTER_CONFIG_NAME = "router";

    public static Map<String, Object> config = Config.getInstance().getJsonMapConfigNoCache(ROUTER_CONFIG_NAME);
    public static SidecarConfig sidecarConfig;
    public static ServerConfig serverConfig = ServerConfig.getInstance();

    public SidecarRouterHandler() {
        super();
        sidecarConfig = SidecarConfig.load();
        if(logger.isDebugEnabled()) logger.debug("SidecarRouterHandler is constructed");
    }

    public void handleRequest(HttpServerExchange httpServerExchange) throws Exception {<FILL_FUNCTION_BODY>}

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

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

    @Override
    public boolean isEnabled() {
        return true;
    }

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

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

        if(logger.isDebugEnabled()) logger.debug("SidecarRouterHandler.handleRequest starts.");
        if (Constants.HEADER.equalsIgnoreCase(sidecarConfig.getEgressIngressIndicator())) {
            HeaderValues serviceIdHeader = httpServerExchange.getRequestHeaders().get(SERVICE_ID);
            String serviceId = serviceIdHeader != null ? serviceIdHeader.peekFirst() : null;
            String serviceUrl = httpServerExchange.getRequestHeaders().getFirst(HttpStringConstants.SERVICE_URL);
            if(logger.isTraceEnabled()) logger.trace("SidecarRouterHandler.handleRequest serviceId {} and serviceUrl {}.", serviceId, serviceUrl);
            if (serviceId != null || serviceUrl != null) {
                if(logger.isTraceEnabled()) logger.trace("SidecarRouterHandler.handleRequest ends with calling RouterHandler");
                proxyHandler.handleRequest(httpServerExchange);
                // get the serviceId and put it into the request as callerId for metrics
                if(serverConfig != null) {
                    httpServerExchange.getRequestHeaders().put(HttpStringConstants.CALLER_ID, serverConfig.getServiceId());
                }
            } else {
                if(logger.isDebugEnabled()) logger.debug("SidecarRouterHandler.handleRequest ends with skipping RouterHandler.");
                Handler.next(httpServerExchange, next);
            }
        } else if (Constants.PROTOCOL.equalsIgnoreCase(sidecarConfig.getEgressIngressIndicator()) && HttpURL.PROTOCOL_HTTP.equalsIgnoreCase(httpServerExchange.getRequestScheme())){
            if(logger.isDebugEnabled()) logger.debug("SidecarRouterHandler.handleRequest ends with calling RouterHandler.");
            proxyHandler.handleRequest(httpServerExchange);
        } else {
            if(logger.isDebugEnabled()) logger.debug("SidecarRouterHandler.handleRequest ends  with skipping RouterHandler.");
            Handler.next(httpServerExchange, next);
        }
    
<methods>public void <init>() ,public void handleRequest(HttpServerExchange) throws java.lang.Exception,public void reload() <variables>private static com.networknt.router.RouterConfig config,private static final Logger logger,protected static com.networknt.metrics.AbstractMetricsHandler metricsHandler,protected static com.networknt.handler.ProxyHandler proxyHandler