Permalink
Browse files

Added support to HttpClient companion for interceptor

  • Loading branch information...
darkfrog26 committed Sep 23, 2018
1 parent d66569f commit d0aac38f099044a8086cfb4188050be187be67d3
View
@@ -3,7 +3,7 @@ import sbtcrossproject.CrossPlugin.autoImport.crossProject
name := "youi"
organization in ThisBuild := "io.youi"
version in ThisBuild := "0.9.0-M20"
version in ThisBuild := "0.9.0-M21-SNAPSHOT"
scalaVersion in ThisBuild := "2.12.6"
crossScalaVersions in ThisBuild := List("2.12.6", "2.11.12")
resolvers in ThisBuild += Resolver.sonatypeRepo("releases")
@@ -1,12 +1,20 @@
package io.youi.client
import io.youi.client.intercept.Interceptor
import scala.concurrent.duration.FiniteDuration
object ClientPlatform {
def createClient(defaultRetries: Int = HttpClient.retries,
defaultRetryDelay: FiniteDuration = HttpClient.retryDelay,
defaultInterceptor: Interceptor = HttpClient.interceptor,
connectionPool: ConnectionPool = HttpClient.connectionPool): HttpClient = {
JSHttpClient(defaultRetries = defaultRetries, defaultRetryDelay = defaultRetryDelay, connectionPool = connectionPool)
JSHttpClient(
defaultRetries = defaultRetries,
defaultRetryDelay = defaultRetryDelay,
defaultInterceptor = defaultInterceptor,
connectionPool = connectionPool
)
}
def createPool(maxIdleConnections: Int = ConnectionPool.maxIdleConnections,
@@ -1,12 +1,20 @@
package io.youi.client
import io.youi.client.intercept.Interceptor
import scala.concurrent.duration.FiniteDuration
object ClientPlatform {
def createClient(defaultRetries: Int = HttpClient.retries,
defaultRetryDelay: FiniteDuration = HttpClient.retryDelay,
defaultInterceptor: Interceptor = HttpClient.interceptor,
connectionPool: ConnectionPool = HttpClient.connectionPool): HttpClient = {
JVMHttpClient(defaultRetries = defaultRetries, defaultRetryDelay = defaultRetryDelay, connectionPool = connectionPool)
JVMHttpClient(
defaultRetries = defaultRetries,
defaultRetryDelay = defaultRetryDelay,
defaultInterceptor = defaultInterceptor,
connectionPool = connectionPool
)
}
def createPool(maxIdleConnections: Int = ConnectionPool.maxIdleConnections,
@@ -150,11 +150,13 @@ trait HttpClient {
object HttpClient {
var retries: Int = 0
var retryDelay: FiniteDuration = 5.seconds
var interceptor: Interceptor = Interceptor.empty
var connectionPool: ConnectionPool = ConnectionPool.default
def apply(defaultRetries: Int = retries,
defaultRetryDelay: FiniteDuration = retryDelay,
defaultInterceptor: Interceptor = interceptor,
connectionPool: ConnectionPool = connectionPool): HttpClient = {
ClientPlatform.createClient(defaultRetries, defaultRetryDelay, connectionPool)
ClientPlatform.createClient(defaultRetries, defaultRetryDelay, defaultInterceptor, connectionPool)
}
}

0 comments on commit d0aac38

Please sign in to comment.