Skip to content

Commit

Permalink
Merge pull request #197 from mash-up-kr/fix/avocado-referer
Browse files Browse the repository at this point in the history
fix: added avocado request referer header
  • Loading branch information
KimDoubleB authored Sep 16, 2024
2 parents ed4b6f6 + 3e521ee commit e6e7758
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import com.piikii.application.domain.place.OriginPlace
import com.piikii.application.port.output.web.OriginPlaceAutoCompletePort
import com.piikii.common.exception.ExceptionCode
import com.piikii.common.exception.PiikiiException
import com.piikii.output.web.avocado.config.AvocadoProperties
import com.piikii.output.web.avocado.parser.AvocadoOriginMapIdParserStrategy
import org.springframework.http.HttpHeaders
import org.springframework.stereotype.Component
import org.springframework.web.client.RestClient
import org.springframework.web.client.body
Expand All @@ -14,6 +16,7 @@ import org.springframework.web.client.body
class AvocadoPlaceAutoCompleteAdapter(
private val avocadoOriginMapIdParserStrategy: AvocadoOriginMapIdParserStrategy,
private val avocadoApiClient: RestClient,
private val avocadoProperties: AvocadoProperties,
) : OriginPlaceAutoCompletePort {
override fun isAutoCompleteSupportedUrl(url: String): Boolean {
return avocadoOriginMapIdParserStrategy.getParserBySupportedUrl(url) != null
Expand All @@ -28,8 +31,10 @@ class AvocadoPlaceAutoCompleteAdapter(
url: String,
originMapId: OriginMapId,
): OriginPlace {
val id = originMapId.toId()
return avocadoApiClient.get()
.uri("/${originMapId.toId()}")
.uri("/$id")
.header(HttpHeaders.REFERER, "${avocadoProperties.url.referer}$id")
.retrieve()
.body<AvocadoPlaceInfoResponse>()
?.toOriginPlace(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ data class AvocadoHttp(
data class AvocadoUrl(
val regex: Regex,
val api: String,
val referer: String,
) {
data class Regex(
val web: String,
Expand Down

0 comments on commit e6e7758

Please sign in to comment.