[NO-ISSUE] Add header

This commit is contained in:
woozu-shin 2024-05-13 19:34:36 +09:00
parent 72bd2a37bc
commit 20c301ea57
7 changed files with 25 additions and 35 deletions

View File

@ -40,7 +40,7 @@ subprojects {
ext { ext {
set('springCloudVersion', "2020.0.4") set('springCloudVersion', "2020.0.4")
set("BASE_IMAGE_REGISTRY_URL", "192.168.0.10:10001") set("BASE_IMAGE_REGISTRY_URL", "registry.myoa-universe.com")
} }
apply from: "${project.rootDir}/jib.gradle" apply from: "${project.rootDir}/jib.gradle"

View File

@ -12,6 +12,7 @@ import org.springframework.context.event.EventListener;
import java.sql.SQLException; import java.sql.SQLException;
@Slf4j @Slf4j
@Profile("!prod")
@Configuration @Configuration
public class H2ConsoleConfiguration { public class H2ConsoleConfiguration {

View File

@ -0,0 +1,19 @@
package com.myoa.engineering.crawl.shopping.configuration.feign;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.apache.http.HttpHeaders;
public class FakeUserAgentInterceptor implements RequestInterceptor {
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(HttpHeaders.USER_AGENT, USER_AGENT_VALUE);
template.header(HttpHeaders.ACCEPT, "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8");
template.header(HttpHeaders.ACCEPT_LANGUAGE, "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7");
template.header(HttpHeaders.USER_AGENT, USER_AGENT_VALUE);
template.header(HttpHeaders.USER_AGENT, USER_AGENT_VALUE);
}
}

View File

@ -9,7 +9,7 @@ public class FmkoreaClientFeignConfiguration {
@Bean @Bean
public RequestInterceptor requestInterceptor() { public RequestInterceptor requestInterceptor() {
return requestTemplate -> new UserAgentInterceptor().apply(requestTemplate); return requestTemplate -> new FakeUserAgentInterceptor().apply(requestTemplate);
} }
} }

View File

@ -1,15 +0,0 @@
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);
}
}

View File

@ -1,5 +1,6 @@
package com.myoa.engineering.crawl.shopping.infra.client.fmkorea; package com.myoa.engineering.crawl.shopping.infra.client.fmkorea;
import com.myoa.engineering.crawl.shopping.configuration.feign.FmkoreaClientFeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap; import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -7,7 +8,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import java.util.Map; import java.util.Map;
@FeignClient(value = "fmkorea-board-client", url = "https://www.fmkorea.com") @FeignClient(value = "fmkorea-board-client", url = "https://www.fmkorea.com",
configuration = FmkoreaClientFeignConfiguration.class)
public interface FmkoreaBoardClient { public interface FmkoreaBoardClient {
@GetMapping("{boardLink}") @GetMapping("{boardLink}")

View File

@ -1,17 +0,0 @@
package com.myoa.engineering.crawl.shopping.infra.client.slack;
import com.myoa.engineering.crawl.shopping.configuration.feign.FeignDefaultConfig;
import com.myoa.engineering.crawl.shopping.dto.slack.v1.SlackMessageDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
@FeignClient(value = "slack-api-client", url = "https://slack.com/api",
configuration = FeignDefaultConfig.class)
public interface SlackAPIClient {
@PostMapping("/chat.postMessage")
String sendMessage(@RequestBody SlackMessageDTO message,
@RequestHeader("Authorization") String token);
}