calaxb_2.12.1.12.1.source-code.httpclients_dispatch0130_async.scala.template Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalaxb_2.12 Show documentation
Show all versions of scalaxb_2.12 Show documentation
scalaxb is an XML data-binding tool for Scala that supports W3C XML Schema (xsd) and wsdl.
The newest version!
package scalaxb
import java.nio.charset.Charset
import scala.concurrent._, duration._
trait DispatchHttpClientsAsync extends HttpClientsAsync {
lazy val httpClient = new DispatchHttpClient {}
def requestTimeout: Duration = 60.seconds
def connectionTimeout: Duration = 5.seconds
trait DispatchHttpClient extends HttpClient {
import dispatch._
// Keep it lazy. See https://github.com/eed3si9n/scalaxb/pull/279
lazy val http = Http.withConfiguration(_.
setRequestTimeout(requestTimeout.toMillis.toInt).
setConnectTimeout(connectionTimeout.toMillis.toInt))
def request(in: String, address: java.net.URI, headers: Map[String, String])(implicit ec: ExecutionContext): Future[String] = {
val req = url(address.toString).setBodyEncoding(Charset.forName("UTF-8")) <:< headers << in
http(req > as.String)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy