Update feign client
This commit is contained in:
parent
365b15e553
commit
53d7ba0bea
|
@ -12,7 +12,6 @@ import org.springframework.context.event.EventListener;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Profile({"datasource-local", "datasource-development"})
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class H2ConsoleConfiguration {
|
public class H2ConsoleConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package com.myoa.engineering.crawl.shopping.configuration;
|
package com.myoa.engineering.crawl.shopping.configuration.feign;
|
||||||
|
|
||||||
import feign.Logger;
|
import feign.Logger;
|
||||||
import feign.RequestInterceptor;
|
import feign.RequestInterceptor;
|
||||||
import feign.codec.ErrorDecoder;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.myoa.engineering.crawl.shopping.configuration.feign;
|
||||||
|
|
||||||
|
import feign.RequestInterceptor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class FmkoreaClientFeignConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RequestInterceptor requestInterceptor() {
|
||||||
|
return requestTemplate -> new UserAgentInterceptor().apply(requestTemplate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.myoa.engineering.crawl.shopping.configuration.feign;
|
||||||
|
|
||||||
|
import feign.RequestInterceptor;
|
||||||
|
import feign.RequestTemplate;
|
||||||
|
|
||||||
|
public class UserAgentInterceptor implements RequestInterceptor {
|
||||||
|
|
||||||
|
private static final String USER_AGENT_HEADER = "User-Agent";
|
||||||
|
private static final String USER_AGENT_VALUE = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(RequestTemplate template) {
|
||||||
|
template.header(USER_AGENT_HEADER, USER_AGENT_VALUE);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,30 +1,35 @@
|
||||||
package com.myoa.engineering.crawl.shopping.controller;
|
package com.myoa.engineering.crawl.shopping.controller;
|
||||||
|
|
||||||
import com.myoa.engineering.crawl.shopping.crawlhandler.PpomppuCrawlDomesticHandler;
|
import com.myoa.engineering.crawl.shopping.crawlhandler.CrawlHandler;
|
||||||
|
import com.myoa.engineering.crawl.shopping.support.dto.constant.CrawlTarget;
|
||||||
import com.slack.api.methods.MethodsClient;
|
import com.slack.api.methods.MethodsClient;
|
||||||
import com.slack.api.methods.SlackApiException;
|
import com.slack.api.methods.SlackApiException;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/exploit")
|
@RequestMapping("/api/v1/exploit")
|
||||||
public class TestAPIController {
|
public class TestAPIController {
|
||||||
|
|
||||||
private final PpomppuCrawlDomesticHandler ppomppuCrawlDomesticHandler;
|
|
||||||
private final MethodsClient methodsClient;
|
private final MethodsClient methodsClient;
|
||||||
|
private final List<CrawlHandler> crawlHandlers;
|
||||||
|
|
||||||
public TestAPIController(PpomppuCrawlDomesticHandler ppomppuCrawlDomesticHandler,
|
|
||||||
MethodsClient methodsClient) {
|
public TestAPIController(MethodsClient methodsClient, List<CrawlHandler> crawlHandlers) {
|
||||||
this.ppomppuCrawlDomesticHandler = ppomppuCrawlDomesticHandler;
|
|
||||||
this.methodsClient = methodsClient;
|
this.methodsClient = methodsClient;
|
||||||
|
this.crawlHandlers = crawlHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/triggers")
|
@GetMapping("/triggers")
|
||||||
public void triggerExploit() {
|
public void triggerExploit(@RequestParam("crawlTarget") CrawlTarget crawlTarget) {
|
||||||
ppomppuCrawlDomesticHandler.handle();
|
crawlHandlers
|
||||||
|
.stream().filter(e -> e.getCrawlTarget().equals(crawlTarget))
|
||||||
|
.forEach(CrawlHandler::handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/test-message")
|
@GetMapping("/test-message")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.myoa.engineering.crawl.shopping.infra.client.slack;
|
package com.myoa.engineering.crawl.shopping.infra.client.slack;
|
||||||
|
|
||||||
import com.myoa.engineering.crawl.shopping.configuration.FeignDefaultConfig;
|
import com.myoa.engineering.crawl.shopping.configuration.feign.FeignDefaultConfig;
|
||||||
import com.myoa.engineering.crawl.shopping.dto.slack.v1.SlackMessageDTO;
|
import com.myoa.engineering.crawl.shopping.dto.slack.v1.SlackMessageDTO;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class ParseEventEmitter {
|
||||||
|
|
||||||
@Scheduled(cron = "0 0/5 * * * ?")
|
@Scheduled(cron = "0 0/5 * * * ?")
|
||||||
public void emit() {
|
public void emit() {
|
||||||
log.info("[emitDomesticBoard] trigger fired!");
|
log.info("[emit] trigger fired!");
|
||||||
crawlHandlers.forEach(CrawlHandler::handle);
|
crawlHandlers.forEach(CrawlHandler::handle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue