class PathServiceHandler implements MiddlewareHandler {
    static Logger logger = LoggerFactory.getLogger(PathServiceHandler.class);
    private volatile HttpHandler next;
    private static PathServiceConfig config;
    public PathServiceHandler() {
        logger.info("PathServiceHandler is constructed");
        config = PathServiceConfig.load();
    }

    @Override
    public void handleRequest(final HttpServerExchange exchange) 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 config.isEnabled();
    }

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

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

        if(logger.isDebugEnabled()) logger.debug("PathServiceConfig.handleRequest starts.");
        // if service URL is in the header, we don't need to do the service discovery with serviceId.
        HeaderValues serviceIdHeader = exchange.getRequestHeaders().get(HttpStringConstants.SERVICE_ID);
        String serviceId = serviceIdHeader != null ? serviceIdHeader.peekFirst() : null;
        if(serviceId == null) {
            Map<String, Object> auditInfo = exchange.getAttachment(AttachmentConstants.AUDIT_INFO);
            if (auditInfo != null) {
                String endpoint = (String) auditInfo.get(Constants.ENDPOINT_STRING);
                if (logger.isDebugEnabled()) logger.debug("endpoint = " + endpoint);
                // now find the mapped serviceId from the mapping.
                if (endpoint != null) {
                    serviceId = config.getMapping() == null ? null : config.getMapping().get(endpoint);
                    if(serviceId != null) {
                        if(logger.isTraceEnabled()) logger.trace("Put into the service_id header for serviceId = " + serviceId);
                        exchange.getRequestHeaders().put(HttpStringConstants.SERVICE_ID, serviceId);
                    } else {
                        if(logger.isDebugEnabled()) logger.debug("The endpoint is not in the mapping config");
                    }
                } else {
                    logger.error("could not get endpoint from the auditInfo.");
                }
            } else {
                // couldn't find auditInfo object in exchange attachment.
                logger.error("could not find auditInfo object in exchange attachment.");
            }
        }
        if(logger.isDebugEnabled()) logger.debug("PathServiceConfig.handleRequest ends.");
        Handler.next(exchange, next);
    
<no_super_class>