package com.bsmlab.dfx.agent.config;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RequiredArgsConstructor
public class WebServerCustomizer implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
    private final AgentConfigReader agentConfigReader;
    @Override
    public void customize(ConfigurableServletWebServerFactory factory) { // 실행확인됨
        int port = agentConfigReader.getAgentConfigDto().getMyListenPort();
        factory.setPort(port);
        factory.setContextPath(""); // context-path 가 "/" root일 때 ""로 입력하여야 함
    }
}
