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