filter(ServerWebExchange exchange, GatewayFilterChain chain) { String reqMthd = exchange.getRequest().getMethod().name(); String reqUri = exchange.getRequest().getURI().getPath(); AdmApiDply api = ApiFactory.getApi(reqMthd, reqUri); boolean shouldBodyRef = false; if (api != null) { exchange.getAttributes().put("api", api); shouldBodyRef = HandlerFactory.isHandlerGroupBodyRef(api.getResHndlr())||"NONE".equals(SystemFactory.getSystem(api.getSysId()).getEdpt().getProt()); } exchange.getAttributes().put("shouldBodyRef", shouldBodyRef); if(shouldBodyRef) { r"> filter(ServerWebExchange exchange, GatewayFilterChain chain) { String reqMthd = exchange.getRequest().getMethod().name(); String reqUri = exchange.getRequest().getURI().getPath(); AdmApiDply api = ApiFactory.getApi(reqMthd, reqUri); boolean shouldBodyRef = false; if (api != null) { exchange.getAttributes().put("api", api); shouldBodyRef = HandlerFactory.isHandlerGroupBodyRef(api.getResHndlr())||"NONE".equals(SystemFactory.getSystem(api.getSysId()).getEdpt().getProt()); } exchange.getAttributes().put("shouldBodyRef", shouldBodyRef); if(shouldBodyRef) { r"> filter(ServerWebExchange exchange, GatewayFilterChain chain) { String reqMthd = exchange.getRequest().getMethod().name(); String reqUri = exchange.getRequest().getURI().getPath(); AdmApiDply api = ApiFactory.getApi(reqMthd, reqUri); boolean shouldBodyRef = false; if (api != null) { exchange.getAttributes().put("api", api); shouldBodyRef = HandlerFactory.isHandlerGroupBodyRef(api.getResHndlr())||"NONE".equals(SystemFactory.getSystem(api.getSysId()).getEdpt().getProt()); } exchange.getAttributes().put("shouldBodyRef", shouldBodyRef); if(shouldBodyRef) { r">
@Component
public class ResponseHandlerBodyRefFilter implements GlobalFilter, Ordered {// 추출과 핸들링 기능 분리
	public static final String RESPONSE_HANDLER = "RESPONSE-HANDLER";
	@Autowired
	private ModifyResponseBodyGatewayFilterFactory modifyResponseBodyGatewayFilterFactory;

	@Autowired
	private ResponseHandlerFilterFunction responseHandlerFilterFunction;

	@Autowired
	CommonLog commonLog;
	
	public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

		String reqMthd = exchange.getRequest().getMethod().name();
		String reqUri = exchange.getRequest().getURI().getPath();

		AdmApiDply api = ApiFactory.getApi(reqMthd, reqUri);
		boolean shouldBodyRef = false;
		if (api != null) {
			exchange.getAttributes().put("api", api);
			shouldBodyRef = HandlerFactory.isHandlerGroupBodyRef(api.getResHndlr())||"NONE".equals(SystemFactory.getSystem(api.getSysId()).getEdpt().getProt());
		}
		exchange.getAttributes().put("shouldBodyRef", shouldBodyRef);
		
		if(shouldBodyRef) {
				return modifyResponseBodyGatewayFilterFactory.apply(
						new ModifyResponseBodyGatewayFilterFactory.Config().setRewriteFunction(byte[].class, byte[].class,
								responseHandlerFilterFunction
						)
				).filter(exchange, chain).then(Mono.fromRunnable(() -> {
					TransactionDto transaction = (TransactionDto) exchange.getAttribute(TransactionDto.TRANSACTION);
					//Thread.currentThread().setName(transaction.getComn().getTxId());
					commonLog.logging(transaction);
				}));
			
		}else{
			return  chain.filter(exchange).then(Mono.fromRunnable(() -> {
				TransactionDto tx = (TransactionDto) exchange.getAttribute(TransactionDto.TRANSACTION);
				commonLog.logging(tx);
			}));
		}
	}

	@Override
	public int getOrder() {
		return -2;
	}
}