Send Maia requests as JSON over HTTP1
This commit is contained in:
@@ -4,6 +4,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties
|
|||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties
|
import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||||
import org.springframework.context.annotation.Bean
|
import org.springframework.context.annotation.Bean
|
||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
|
import org.springframework.http.client.SimpleClientHttpRequestFactory
|
||||||
import org.springframework.web.client.RestClient
|
import org.springframework.web.client.RestClient
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
|
|
||||||
@@ -16,8 +17,13 @@ class MaiaConfig {
|
|||||||
builder: RestClient.Builder,
|
builder: RestClient.Builder,
|
||||||
properties: MaiaProperties
|
properties: MaiaProperties
|
||||||
): RestClient {
|
): RestClient {
|
||||||
|
val requestFactory = SimpleClientHttpRequestFactory().apply {
|
||||||
|
setConnectTimeout(Duration.ofSeconds(5))
|
||||||
|
setReadTimeout(Duration.ofSeconds(120))
|
||||||
|
}
|
||||||
return builder
|
return builder
|
||||||
.baseUrl(properties.engineUrl)
|
.baseUrl(properties.engineUrl)
|
||||||
|
.requestFactory(requestFactory)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package me.wypark.blogbackend.domain.chess
|
package me.wypark.blogbackend.domain.chess
|
||||||
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
import org.springframework.http.MediaType
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
import org.springframework.web.client.RestClient
|
import org.springframework.web.client.RestClient
|
||||||
import org.springframework.web.client.RestClientException
|
import org.springframework.web.client.RestClientException
|
||||||
@@ -26,6 +27,8 @@ class MaiaEngineClient(
|
|||||||
return maiaRestClient
|
return maiaRestClient
|
||||||
.post()
|
.post()
|
||||||
.uri(path)
|
.uri(path)
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.accept(MediaType.APPLICATION_JSON)
|
||||||
.body(request)
|
.body(request)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.body(responseType)
|
.body(responseType)
|
||||||
|
|||||||
Reference in New Issue
Block a user